Page 1 of 1

Volume Series with all zero values

Posted: Fri Oct 05, 2007 10:45 am
by 7665742
Hi:

We have some datasets with 0 as the value for volume. When we draw volume series for these values, we are getting horizontal axis drawn in the middle of the custom axis. But, what we would like to have is nothing drawn if all the values are ZERO. Is this possible? Any inputs are appreciated. Thank you.

best regards,
vasu[/img]

Posted: Tue Oct 09, 2007 12:40 am
by Tom
Hi,

(There are several ways).

You can set the visibility of the series to false, if all values are 0. There are several methods which can give you an idea if the series contains only 0 values, among the getMaxYValue() and getMinYValue().

Code: Select all

if (volumeSeries.getMaxYValue()==0 && volumeSeries.getMinYValue()==0) {
   volumeSeries.setVisible(false); 
}
Depending on your code on how you fill the series, you can use an event to call the above code. As example (but far from optimal and recommended not to be used) the following will check the volumeSeries each time just before the chart will be painted:

Code: Select all

        myChart.addChartPaintListener( new ChartPaintAdapter() {
            public void chartPainting(ChartDrawEvent e) {
                if (volumeSeries.getMaxYValue()==0 && volumeSeries.getMinYValue()==0) {
                    volumeSeries.setVisible(false); 
                };
            };
        };
Regards,
tom