Hide/show series in Achartengine

2019-07-30 09:41发布

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);

2条回答
干净又极端
2楼-- · 2019-07-30 10:29

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.

查看更多
祖国的老花朵
3楼-- · 2019-07-30 10:36

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.

查看更多
登录 后发表回答