How to update/remove/insert new series/data in Shinobi Line Chart in android?

泪湿孤枕 提交于 2019-12-13 04:15:18

问题


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:


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.



来源:https://stackoverflow.com/questions/25890132/how-to-update-remove-insert-new-series-data-in-shinobi-line-chart-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!