A discussion forum for JFreeChart (a 2D chart library for the Java platform).
-
mminer
- Posts: 11
- Joined: Wed Jun 06, 2007 8:11 pm
Post
by mminer » Wed Aug 01, 2007 9:17 pm
I have a CategoryPlot rendered by a BoxAndWhiskerRenderer. On this plot I have a DefaultBoxAndWhiskerCategoryDataset, which contains twelve items. I would like to temporarily hide a row on this dataset, or even the whole thing. However, I'm unable to do so. I would expect the following code to hide something, but it seems to have no effect (the zero can be substituted for any number).
Code: Select all
CategoryPlot plot = (CategoryPlot)getPlot();
Boolean visible = new Boolean(false);
plot.getRenderer().setSeriesVisible(0, visible);
Any ideas? Is it simply not possible to hide items rendered by a BoxAndWhiskerRenderer?
-
Priya Shivapura
- Posts: 59
- Joined: Fri Feb 23, 2007 7:41 am
Post
by Priya Shivapura » Thu Aug 02, 2007 5:16 pm
Looks like this is a bug in the BoxAndWhiskerRenderer. The visibility is not being checked when the items are being drawn. For now, you could extend the BoxAndWhiskerRenderer, override the drawHorizontalItem and drawVerticalItem and add the following two lines in the beginning
Code: Select all
// do nothing if item is not visible
if (!getItemVisible(row, column)) {
return;
}
Regards,
Priya
-
RichardWest
- Posts: 844
- Joined: Fri Oct 13, 2006 9:29 pm
- Location: Sunnyvale, CA
Post
by RichardWest » Thu Aug 02, 2007 5:30 pm
Priya Shivapura wrote:Looks like this is a bug in the BoxAndWhiskerRenderer.
I would not necessarily say this is a bug. When the setSeriesVisibility() method was added, not all renderers implemented it. The reason being is that some renderers rely on information from all the series to render correctly, and the visibilty complicates the logic. The body fir this method has been written on a per demand/per available-time basis.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
-
mminer
- Posts: 11
- Joined: Wed Jun 06, 2007 8:11 pm
Post
by mminer » Wed Aug 08, 2007 3:50 pm
Priya Shivapura wrote:For now, you could extend the BoxAndWhiskerRenderer, override the drawHorizontalItem and drawVerticalItem and add the following two lines in the beginning
Thanks Priya, that worked like a charm.
Though it may not be a bug, it certainly seems like it is when the setSeriesVisibility() does nothing despite being given the proper index of the series. The API documentation for CategoryItemRenderer gives no hint that the method may not work in some of its subclasses.
-
Paul Belleville
- Posts: 15
- Joined: Wed Nov 07, 2007 6:20 pm
Post
by Paul Belleville » Wed Oct 01, 2008 9:49 pm
I used this work around, and it works great.
I am using 1.0.9. Does anyone know if it is implemented in the newest version such that I don't need the work-around?
-
david.gilbert
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
-
Contact:
Post
by david.gilbert » Thu Oct 02, 2008 8:16 am
No it's not. I'm adding it now for the 1.0.12 release.