I've got more of a question than a problem. I'm creating an application with drop down spinners to select the time window and data set to be updated and displayed in a single XYplot view via a line chart.
I'll post the code but I'm basically failing to find in the API documentation the methods to update() or reset() the graph.
Collections.sort(statistics, (one, two) -> Integer.compare(Integer.parseInt(one.getId()), Integer.parseInt(two.getId())));
Number[] xVals = new Number[statistics.size()];
Number[] yVals = new Number[statistics.size()];
for (int i = 0; i < statistics.size(); i++) {
Statistic statistic = statistics.get(i);
xVals[i] = Integer.parseInt(statistic.getId());
switch (dataMode) {
case 0://Gross
yVals[i] = statistic.getGross();
break;
case 1://Balance
yVals[i] = statistic.getBalance();
break;
case 2://Miles
yVals[i] = statistic.getMiles();
break;
case 3://Net CPM
yVals[i] = statistic.getNetCpm();
break;
default://Fuel Price
yVals[i] = statistic.getFuelPrice();
break;
}
}
Logger.i("Xvals " + yVals.length, MainActivity.gson.toJson(xVals));
Logger.i("Yvals " + xVals.length, MainActivity.gson.toJson(yVals));
series = new SimpleXYSeries(Arrays.asList(xVals), Arrays.asList(yVals), "Series");
LineAndPointFormatter series1Format = new LineAndPointFormatter(Color.RED, Color.GREEN, Color.BLUE, null);
series1Format.setInterpolationParams(new CatmullRomInterpolator.Params(10, CatmullRomInterpolator.Type.Centripetal));
graphView.addSeries(series, series1Format);
An example of the x and y value arrays are as follows
My spinner OnItemSelectedListeners() are being triggered and the new data is logged and added to the graph. Ive tried both removeSeries() and clear() on the plot
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
graphView.removeSeries(series);
graphView.clear();
switch (adapterView.getId()) {
case R.id.dataSet:
dataMode = i;
calculateAverages(false);
break;
case R.id.timeFrame:
timeMode = i;
calculateAverages(false);
break;
}
}
What am I missing here? How to set the new series and update the graph?
I've got more of a question than a problem. I'm creating an application with drop down spinners to select the time window and data set to be updated and displayed in a single XYplot view via a line chart.
I'll post the code but I'm basically failing to find in the API documentation the methods to update() or reset() the graph.
An example of the x and y value arrays are as follows
Using the spinners I'll run the same code above which results in alternative data
My spinner OnItemSelectedListeners() are being triggered and the new data is logged and added to the graph. Ive tried both removeSeries() and clear() on the plot
What am I missing here? How to set the new series and update the graph?