Setting horizontal axis value

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
rubanj82
Posts: 1
Joined: Tue Apr 11, 2006 8:14 am

Setting horizontal axis value

Post by rubanj82 » Tue Apr 11, 2006 10:32 am

Hi

I have set values for horizal(X-axis) i have the dataset as

XYSeries xydataset = new XYSeries("Height");

xydataset.add(0, 30);
xydataset.add(3, 45);
xydataset.add(6, 65);
xydataset.add(9, 75);
xydataset.add(12, 78);
xydataset.add(15, 80);
xydataset.add(18, 81);
xydataset.add(21, 83);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(xydataset);
JFreeChart jfreechart = ChartFactory.createXYLineChart("Growth Chart",
"Age", "Height in Cms", dataset, PlotOrientation.VERTICAL,
true, true, false);

but in the graph im getting auto range values,but i want it as 3 6 9 12.. how to get this

Bye

doudou
Posts: 27
Joined: Tue Mar 14, 2006 6:05 pm

Post by doudou » Tue Apr 11, 2006 11:08 am

there should be a property of the axis to set this.
Make a search on "tick units" and ValueAxis on the forum, you should find everything you need.

Sorry, I'm not a guru yet so I can only show the path :oops:

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 » Tue Apr 11, 2006 5:48 pm

You can do something like:

Code: Select all

XYPlot plot = (XYPlot) jfreechart.getPlot();
NumberAxis axis = (NumberAxis) plot.getDomainAxis();
axis.setTickUnit(new NumberTickUnit(3.0));
David Gilbert
JFreeChart Project Leader

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

Locked