Restricting Y-axis values
Restricting Y-axis values
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
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
-
- Posts: 16
- Joined: Wed Aug 31, 2005 4:25 pm
If you have a NumberAxis in your plot and assuming you have your y-axis try:
If you don't already have a reference to the axis, use the getMethods provided by the plot your using.
Cheers Christopher
Code: Select all
yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
Cheers Christopher
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
http://cewolf.sourceforge.net/new/tutorial/step2.html
Where should i write the code you mentioned?
please guide me step by step
Thanks
-adnan
-
- Posts: 16
- Joined: Wed Aug 31, 2005 4:25 pm
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
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
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]
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]
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
I think your chart is using CategoryPlot not XYPlot.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

