legends visibility

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
prx

legends visibility

Post by prx » Tue Nov 08, 2005 7:51 pm

Hi.

I want set visibility of LEGEND or/and LABELS
in Pie Charts to false . Is it possible? How?

Thanks.

dhchou
Posts: 138
Joined: Tue Jul 05, 2005 11:01 pm

Post by dhchou » Tue Nov 08, 2005 7:57 pm

To remove legend use the removeLegend method in JFreeChart class.

Daniel

reden
Posts: 6
Joined: Tue Nov 22, 2005 11:46 pm

Post by reden » Fri Dec 02, 2005 7:54 am

dhchou wrote:To remove legend use the removeLegend method in JFreeChart class.
Thanks for the pointer. If the legend is removed, can it be added back without rebuilding the entire chart? We have an interactive builder that displays the chart changes as the user modifies the settings. If they choose to hide the legend and then choose to show it... it appears that there's currently no way to add it back.

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 » Fri Dec 02, 2005 2:45 pm

You can use the addLegend() method in the JFreeChart class. You might run into a problem with the fact that the legend is added to the chart as a subtitle, and its position in the subtitle list affects its position on the chart. So there may be cases where you have to fetch all the subtitles, clear the subtitles from the chart, then add them back in the order you need. That suggests, of course, that a 'visible' flag on the LegendTitle would make things easier...and very likely I'll add one, but it won't be in time for the 1.0.0 release.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

reden
Posts: 6
Joined: Tue Nov 22, 2005 11:46 pm

Post by reden » Fri Dec 02, 2005 5:52 pm

Ah, thanks. I was still using RC 1 which didn't have that method. I'm on 1.0.0 now! :D

Locked