Hi folks,
I have a situation where a dataset coming from the database contains only zeros (price on the value axis) for the values for each day of a month (the category axis).
In the situation where all the values are zero, I notice that on the bar chart 0E0 is rendered in the middle of the value axis with 5E-9 at the top and -5E-9 at the bottom. It doesn't look quite right.
Is there a way to set a default range in this case between 0 and 20, for example.
Normally a chart would render between 0 and some arbitrary value... I'm not sure I know what the maximum can be.
I figured I could set the auto range something like this:
ValueAxis rangeAxis = plot.getRangeAxis();
rangeAxis.setDefaultAutoRange( new Range( 0, 20 ) );
But this (and others) don't appear to work in the zero-case scenario above.
Many thanks.
Autorange on ValueAxis
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: Autorange on ValueAxis
The defaultAutoRange attribute is only used when there is no data in the dataset.
Where there is data, but it has a constant value (such as zero) the measured range has length zero ... for this you can use the setAutoRangeMinimumSize(double) method to specify what the actual length should be. It might not do exactly what you want though, since if you specify a minimum length of 20 it will result in a range from -10 to 10 for the case where the dataset contains all zeros.
Where there is data, but it has a constant value (such as zero) the measured range has length zero ... for this you can use the setAutoRangeMinimumSize(double) method to specify what the actual length should be. It might not do exactly what you want though, since if you specify a minimum length of 20 it will result in a range from -10 to 10 for the case where the dataset contains all zeros.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
Re: Autorange on ValueAxis
Thanks David,
I thought it might not look exactly right but on reflection it looks perfect now! Thanks!
Graeme.
I thought it might not look exactly right but on reflection it looks perfect now! Thanks!
Graeme.