I am using jfreechart 1.0.9.
I am using the StackedXYBarRenderer and when I try to hide a series using the setSeriesVisible method, it does not work.
The legend item for the particular series gets hidden, but the series bars withing the graph do not disappear.
((StackedXYBarRenderer)((XYPlot) plot).getRenderer()).setSeriesVisible(i, false);
Let me know if you have seen this and if you have a solution.
Thanks
Paul B.
StackedXYBarRenderer method setSeriesVisible does not work
-
- Posts: 15
- Joined: Wed Nov 07, 2007 6:20 pm
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Not all renderers care about the flag(s) that determine whether an item or a series should be visible or not. The right place to perform this check is the start of the drawItem-method. The parameter list contains the series and the item index. One of the first lines in every renderer should be like the following:
If you check the source code of the StackedXYBarRenderer class (i.e. the drawItem method) you will see that this check is indeed missing.
Solution: edit the source and recompile.
Code: Select all
if (!getItemVisible(series, item) || !getSeriesVisible(series)) {
return;
}
Solution: edit the source and recompile.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
This minor complication combined with my own laziness has led to the "series visible flag" being ignored by many of the bar renderers. It would be nice to have this working correctly.skunk wrote:Don't forget that you will also need to add code that checks the series visibility flag when calculating the aggregate height of each stack
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

