How to update/remove/insert new series/data in Shi

2019-09-18 15:55发布

I am updating the chart but it showing old series also. How to update/remove/insert new series/data in Shinobi Line Chart in android?

I am using this code:

        CategoryAxis xAxis = new CategoryAxis();

        xAxis.enableGesturePanning(true);
        xAxis.enableGestureZooming(true);

        xAxis.setRangePaddingHigh(0.3);
        xAxis.setRangePaddingLow(0.1);

        shinobiChart.setXAxis(xAxis);

        NumberAxis yAxis = new NumberAxis();
        yAxis.setMajorTickFrequency(200.0);
        yAxis.enableGesturePanning(true);
        yAxis.enableGestureZooming(true);

        shinobiChart.setYAxis(yAxis);
        yAxis.setDefaultRange(new NumberRange(-50.0, 1024.0));

1条回答
Bombasti
2楼-- · 2019-09-18 16:20

There are several ways in which you can add / remove / update data in a LineSeries.

To change the data that the LineSeries is showing you can add or remove data points from the series' underlying DataAdapter. As data is added or removed a redraw of the chart will take place and as such you will immediately see the changes to the series on the chart.

To add data points to the DataAdapter you can use one of the add methods such as that described below:

http://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.5.1/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/DataAdapter.html#add(com.shinobicontrols.charts.Data)

To remove data points from the DataAdapter you can use one of the remove methods such as that described below:

http://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.5.1/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/DataAdapter.html#remove(int)

Your second option, which is maybe a little more severe is to remove the existing series completely and replace it with a new one.

There are numerous examples of how to add a series to a chart within the sample apps which are bundled with ShinobiCharts for Android. If you do add a new series and wish to no longer see the previous, old series it is very important that you remember to remove the old series using the method described below:

http://www.shinobicontrols.com/docs/ShinobiControls/ShinobiChartsAndroid/1.5.1/Premium/Normal/apidocs/docs/reference/com/shinobicontrols/charts/ShinobiChart.html#removeSeries(com.shinobicontrols.charts.Series)

I hope this helps. If you need further help by all means post back.

Thanks, Kai. Disclaimer - I work for ShinobiControls.

查看更多
登录 后发表回答