Skip to content

Commit 6ad316d

Browse files
committed
Static realtime sample
1 parent 1ff5d3c commit 6ad316d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/LineChartTime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private void setData(int count) {
136136
if (count == 100) // initial
137137
y = (valuesData[Math.round(x)]).floatValue() * 50 + 50;
138138
else
139-
y = (float) (Math.random() * 50 + 50);
139+
y = (float) (Math.random() * 50 + 50); // manually triggered
140140
values.add(new Entry(x, y)); // add one entry per hour
141141
}
142142

MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/RealtimeLineChartActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class RealtimeLineChartActivity extends DemoBase implements
3333
OnChartValueSelectedListener {
3434

3535
private LineChart chart;
36+
Double[] sampleValues = DataTools.Companion.getValues(102);
3637

3738
@Override
3839
protected void onCreate(Bundle savedInstanceState) {
@@ -110,7 +111,8 @@ private void addEntry() {
110111
data.addDataSet(set);
111112
}
112113

113-
data.addEntry(new Entry(set.getEntryCount(), (float) (Math.random() * 40) + 30f), 0);
114+
int cycleValue = (int) (set.getEntryCount() % 100.0);
115+
data.addEntry(new Entry(set.getEntryCount(), (float) (sampleValues[cycleValue].floatValue() * 40) + 30f), 0);
114116
data.notifyDataChanged();
115117

116118
// let the chart know it's data has changed

0 commit comments

Comments
 (0)