Y axis values not displayed in JChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Swapna K
Posts: 5
Joined: Wed Apr 02, 2014 8:25 pm
antibot: No, of course not.

Y axis values not displayed in JChart

Post by Swapna K » Wed Apr 02, 2014 8:34 pm

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

Swapna K
Posts: 5
Joined: Wed Apr 02, 2014 8:25 pm
antibot: No, of course not.

Re: Y axis values not displayed in JChart

Post by Swapna K » Fri Apr 04, 2014 6:57 pm

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

david.gilbert
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

Post by david.gilbert » Fri Apr 04, 2014 9:34 pm

This line in your code makes the axis display integer values only, so it can't show tick marks between 0 and 1:

Code: Select all

testYAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
The easiest solution would be to remove that line and let the axis do its default tick selection.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Swapna K
Posts: 5
Joined: Wed Apr 02, 2014 8:25 pm
antibot: No, of course not.

Re: Y axis values not displayed in JChart

Post by Swapna K » Mon Apr 07, 2014 6:12 pm

Thank you for the solution, I tried it and it was displaying the values.

Swapna K
Posts: 5
Joined: Wed Apr 02, 2014 8:25 pm
antibot: No, of course not.

Re: Y axis values not displayed in JChart

Post by Swapna K » Mon Apr 07, 2014 6:37 pm

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.

Swapna K
Posts: 5
Joined: Wed Apr 02, 2014 8:25 pm
antibot: No, of course not.

Re: Y axis values not displayed in JChart

Post by Swapna K » Mon Apr 07, 2014 8:25 pm

I tried with the below solution and it worked for me.

DecimalFormat df=new DecimalFormat();
df.applyPattern("0.###");
testYAxis.setNumberFormatOverride(df);

Locked