Dynamic clickable legend

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
truman
Posts: 1
Joined: Sat Sep 08, 2007 11:18 am

Dynamic clickable legend

Post by truman » Sat Sep 08, 2007 11:20 am

Is it possible, in a line chart, to customize legend, having for each item a checkbox to show/hide items in chart?

:shock:

thanks, bye

RichardWest
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

Re: Dynamic clickable legend

Post by RichardWest » Sat Sep 08, 2007 7:41 pm

truman wrote:Is it possible, in a line chart, to customize legend, having for each item a checkbox to show/hide items in chart?
Yes. Take a look at HideSeriesDemo1 in the demo. If you have bought the Developer's Guide, you can view the source code.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

Alphonse87
Posts: 9
Joined: Thu May 08, 2008 3:18 pm

Post by Alphonse87 » Thu May 08, 2008 3:27 pm

Hi !

I reply because I wanted to do the same thing ( and I don't have the Developper's Guide ).

So I try to use this function : ( extract from the javadoc jfreechart/api/javadoc/index.html )

Code: Select all

public void setSeriesVisible(int series, java.lang.Boolean visible)
This is a part of my code :

Code: Select all

XYItemRenderer renderer = (XYItemRenderer) plot.getRenderer();	
renderer.setSeriesVisible(0, true);
It's seems to be good for me, but Eclipse doesn't agree :
The method setSeriesVisible(Boolean, boolean) in the type XYItemRenderer is not applicable for the
arguments (int, boolean)
Someone sees what's wrong ?

Edit : Me ...

I was searching in the wrong way ...
I have no errors with this code :

Code: Select all

XYItemRenderer renderer = (XYItemRenderer) plot.getRenderer();	
renderer.setSeriesVisible(1, new Boolean(true));

Locked