|
Values appear more than once on y-axis |
Posted by Michael Opitz on Dec-05-2008 17:17 |
|
Hi Peter,
i have an other question regarding y-values on a X-Y-Chart.
When I have very small values (between 0 and 20) and only "natural" numbers (from 1 to 20) without fractions, then sometimes I see values on the y axis more than once (see picture).
I would like to use
axis.setAutoScale(0.1, 0.1, 1);
but then, I have fraction labels, which I do not want. So I use this code:
NumberFormat nf = ...;
if (null != nf && nf.getMaximumFractionDigits() == 0 && maxValue >= 1 && maxValue < 10) {
axis.setLinearScale(0, maxValue+1, 1);
} else {
axis.setAutoScale(0.1, 0.1, 1);
}
but then I have the same problem, when my range is greater than 10.
Is there a better way to prevent the values to appear more than once or what is the limit to switch to LinearScale with stepWidth 1?
The range is highly customizable to our customers, but they do not want to always set the range manually, so I need a more intelligent auto-mode.
Regards,
Michael
|
Re: Values appear more than once on y-axis |
Posted by Peter Kwan on Dec-06-2008 00:38 |
|
Hi Michael,
The values on the y-axis should not repeat, but the axis labels may look the same if the label format cuts alway part of the values so you cannot see the real values. In your case, I think there may be a line of code that cuts away the fractional part of the value (so both 10.5 and 11.0 will appear as 11).
For your case, you may use Axis.setMinTickInc to ask ChartDirector auto-scaling to ensure a minimum tick spacing of 1. In this way, there will not be fractional values on the axis. The code is like:
axis.setMinTickInc(1);
Hope this can help.
Regards
Peter Kwan |
|