vertical axis units

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

vertical axis units

Post by ben zad » Mon Feb 11, 2002 10:38 am

Hi

Im using the Vertical Stacked 3D Bar chart.

I want the Vertical Axis Units to be in the form 0.00 and to jump
by 0.20 .
example: 0, 0.20, 0.40 etc.

How exactly do I do this.

thanks very much,

Ben

David Gilbert

Re: vertical axis units

Post by David Gilbert » Mon Feb 11, 2002 6:42 pm

Hi Ben,

In the NumberAxis class there is a method setTickUnit(...) that will allow you to override the automatic tick selection mechanism and use a fixed tick value. You'll need to do something like this:

BarPlot plot = (BarPlot)myChart.getPlot();
NumberAxis axis = (NumberAxis)plot.getRangeAxis();
NumberTickUnit unit =new NumberTickUnit(new Double(0.2), new DecimalFormat("0.00"));
axis.setTickUnit(unit);
Regards,

Dave Gilbert

ravikanth

Re: vertical axis units

Post by ravikanth » Wed Feb 20, 2002 7:59 am

hello
i want to create a Bargraph with predifined range on values axis.
after creating the chart as per demo example i wrote this code.

iam getting an error as getRangeAxis() can not resolved.
i have seen online documentaion that this method is not there in
BarPlot or Plot.
how to solve this problem.pl help me immediately


JFreeChart chart = ChartFactory.createVerticalBarChart("Say/Do Metrics tool,IBC",
"Categories", "Values", categoryData, true);
Plot bPlot = (BarPlot)chart.getPlot();
HorizontalCategoryAxis cAxis = (HorizontalCategoryAxis)bPlot.getAxis(Plot.HORIZONTAL_AXIS);
cAxis.setVerticalCategoryLabels(true);
NumberAxis axis = (NumberAxis)bPlot.getRangeAxis();
NumberTickUnit unit =new NumberTickUnit(new Double(0.2), new DecimalFormat("0.00"));
axis.setTickUnit(unit);

Locked