Hi,
I am new to JChart and have an issue where my Y axis values are not displayed as the values are very less like 0.001 , 0.0002 , less than 1, if the values are more than 1, the graph is displayed correctly . My code is something like below, I tried using the range attribute but that is not working. Any pointers is greatly appreciated.
NumberAxis testYAxis = new NumberAxis(label);
testYAxis.setAutoRangeIncludesZero(true);
testYAxis.setLabelPaint(Color.WHITE);
testYAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
Regards,
Swapna
Y axis values not displayed in JChart
Re: Y axis values not displayed in JChart
Attaching a screenshot of the issue where no values are displayed when the values are in the range 0-1.
[img]
https://imageshack.com/i/n14qkxp
[/img]
Using JRE 7 and JFreeChart 1.0.13
Appreciate any help/pointers.
Thanks,
Swapna
[img]
https://imageshack.com/i/n14qkxp
[/img]
Using JRE 7 and JFreeChart 1.0.13
Appreciate any help/pointers.
Thanks,
Swapna
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: Y axis values not displayed in JChart
This line in your code makes the axis display integer values only, so it can't show tick marks between 0 and 1:
The easiest solution would be to remove that line and let the axis do its default tick selection.
Code: Select all
testYAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
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: Y axis values not displayed in JChart
Thank you for the solution, I tried it and it was displaying the values.
Re: Y axis values not displayed in JChart
The values are getting displayed fine on the graph when the range is 0-1 Eg: 0.000, 0.025, 0.05 etc and so on but when my graph doesn't have any other values other than 0, it displays as 0.0000000(seven zeroes). Is there a way I can display it as 0.0. Please advice.
Re: Y axis values not displayed in JChart
I tried with the below solution and it worked for me.
DecimalFormat df=new DecimalFormat();
df.applyPattern("0.###");
testYAxis.setNumberFormatOverride(df);
DecimalFormat df=new DecimalFormat();
df.applyPattern("0.###");
testYAxis.setNumberFormatOverride(df);