问题
I have a dataset with 10 series in a Linechart.
I need to hide a serie when user click a button, and show it when user clicks again.
Is this possible with Achartengine.
Thanks.
A sample of the code:
XYSeriesRenderer r01 = new XYSeriesRenderer();
r01.setColor(Color.YELLOW);
r01.setPointStyle(PointStyle.CIRCLE);
r01.setFillBelowLine(true);
r01.setFillBelowLineColor(Color.YELLOW);
r01.setFillPoints(true);
r01.setLineWidth(4);
mRenderer.addSeriesRenderer(r01);
回答1:
One simple way is that you can set the renderer series color to "Color.TRANSPARENT", that's a 'pseudo' hiding. However, you may need to adjust the scale if you have some extreme figures.
A more complicated way would be using removeSeries() to remove all the current series and add the necessary one back to it again.
回答2:
Just remove the series and its renderer when you want to hide it and when you want it displayed, add it back and don't forget the renderer, again. You will probably have to call a repaint() on the view after each such operation.
来源:https://stackoverflow.com/questions/10640405/hide-show-series-in-achartengine