Barchart - need to hide bars frm chart and legend if value=0

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
sana
Posts: 1
Joined: Thu Aug 28, 2008 10:11 am
Location: Colombo

Barchart - need to hide bars frm chart and legend if value=0

Post by sana » Thu Aug 28, 2008 10:34 am

Hi All,
I have implemented a bar chart using Jfreechart and in that chart I have 8 bars. most of the time the non zero values come for few bars not for all.

The problem that I have is that the zero values bars are also taking a space in the chart and they do appear in the legend too.

I need to remove or hide the zero valued bars from the chart and legend.
IS THIS possible?

any help or idea that you give in this context would be highly appreciated.

My Jfreechart version is 1.0.10

flash
Posts: 6
Joined: Wed Sep 10, 2008 5:22 am

Post by flash » Fri Sep 19, 2008 5:09 am

Hi,

Yes I would like to know how to do this too, quite often you need to to add "null" values doing something like

Code: Select all

defaultcategorydataset2.addValue(null, className, period);
and then it appears in the legend.

is there a quick way to remove these legends?

Locked