Restricting Y-axis values

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Adnan Siddiqi

Restricting Y-axis values

Post by Adnan Siddiqi » Wed Aug 31, 2005 12:45 pm

Hi

i am using Cewolf which uses Jfreechart,i have a range of values from 0-5 for Y-axis,instead of showing 0,1,2,3... ,it displays as 0.0,0.5,1.0 and it makes more than 10 marks to reach upto 5.


how can i restrict it upto 5 marks only that is 0,1,2,in short,displaying values in Integer format

Thanks

christopher.loerken
Posts: 16
Joined: Wed Aug 31, 2005 4:25 pm

Post by christopher.loerken » Wed Aug 31, 2005 4:53 pm

If you have a NumberAxis in your plot and assuming you have your y-axis try:

Code: Select all

yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
If you don't already have a reference to the axis, use the getMethods provided by the plot your using.

Cheers Christopher

Guest

Post by Guest » Thu Sep 01, 2005 6:32 am

Thanks for reply but i am stilll confused,in the following example,

http://cewolf.sourceforge.net/new/tutorial/step2.html

Where should i write the code you mentioned?

please guide me step by step

Thanks

-adnan

christopher.loerken
Posts: 16
Joined: Wed Aug 31, 2005 4:25 pm

Post by christopher.loerken » Thu Sep 01, 2005 8:42 am

Hi Adnan,
I'm afraid that, in your example, you can't...
The axes are attached to the plot, not the Dataset.

The structure is that you have the data in a series, the series in a Dataset, the Dataset in a plot and the plot in a chart.

And as the axes are property of the plot you cannot specify them by just creating a dataset as that doesn't know anything about them...

You might have to look deeper into how Cewolf handles the actual creation of the Charts.

Unfortunately I'm not familiar to Cewolf at all so I have no idea where you might find what you need.
I hope I could help anaway,
cheers
Christopher

Adnan Siddiqi

Post by Adnan Siddiqi » Thu Sep 01, 2005 11:36 am

I tried and getting following exception:

http://www.geocities.com/r_ali_s2000/blogs/chart.jpg

the thing i tried was:

[code]XYPlot plot = (XYPlot)((JFreeChart)chart).getPlot();
NumberAxis yAxis = (NumberAxis)plot.getRangeAxis(); [/code]

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Sep 01, 2005 11:37 am

I think your chart is using CategoryPlot not XYPlot.
David Gilbert
JFreeChart Project Leader

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

Adnan Siddiqi

Post by Adnan Siddiqi » Thu Sep 01, 2005 11:52 am

David how can i check this and what should be the alternative?

Thanks

Adnan Siddiqi

Post by Adnan Siddiqi » Thu Sep 01, 2005 12:11 pm

OK i solved it but width of Grid is very big if the range is small (0-5)

can i make Grid less wider?

Thanks

Locked