Open Blogshot opened 6 years ago
It's working for me:
Take this example code as base:
// generate unique timetamps
long[] timestamps = new long[]{100000000L, 155269656L, 156023040L, 400000003L, 600000000L};
double worthAtTimestamp = 3.43;
double worthAtTimestamp2 = 9.23;
// we just aggregated timestamps, now sum up the balance at each timestamp
DataPoint[] points = new DataPoint[timestamps.length];
int index=0;
for (long timestamp:timestamps) {
//Adding abit of variation in the chart(if position mod of 5 write 3.43 else 9.23)
points[index++] = new DataPoint(timestamp,
(timestamp%5==0)?worthAtTimestamp:worthAtTimestamp2);
}
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(points);
series.setDrawBackground(true);
series.setDrawDataPoints(true);
graphQuality.addSeries(series);
graphQuality.getGridLabelRenderer().setHorizontalLabelsAngle(90);
graphQuality.getGridLabelRenderer().setNumHorizontalLabels(4);
graphQuality.getViewport().setMaxX(timestamps[timestamps.length-1]);
graphQuality.getViewport().setMaxY(10);
graphQuality.getViewport().setMinX(0);
How its look like:
(I would close this but i dont think i can)
Hello there!
I'm adding datapoints to my graph. Sadly, the graph neither scrolls to the first point, nor seems to at least update its view. I'm trying to take a list of transactions and display a history of total balance.
My code:
Log:
Layout:
Screenshot: https://image.ibb.co/i9j5ob/device_2018_01_27_150237.png
I can see some blue line at the left end of the graph which doesn't correspond to the data I've put in.
Any ideas what I'm doing wrong?