dual axis chart with both axis values set by user

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
vairamuthum
Posts: 9
Joined: Tue Jul 11, 2006 8:10 am
Location: Delhi
Contact:

dual axis chart with both axis values set by user

Post by vairamuthum » Wed Aug 02, 2006 5:04 am

Dear Dave and all,
This is the coding i used for making dual axis chart and the chart i got is comprising of four bars.I want only two bars to be shown but there are four bars and overlapping also.I have posted two more forums regarding this one and axis range to be set.But i didn't get any reply?

String seriesNames = "Months";
Color bgColor = new Color(205,211,214);
//Line Parameters
String line1="Total No.of Milestones";
String line2="Total Unbilled Amount";

//Row Names
// String[] monthsname=new string[] {"April","May","June","July"};
String month1="Mar,06";
String month2="Apr,06";
String month3="May,06";
String month4="June,06";


// creating Dataset
DefaultCategoryDataset dataset = new DefaultCategoryDataset();

dataset.addValue(85, line1,month1);
dataset.addValue(100, line1,month2);
dataset.addValue(125, line1,month3);
dataset.addValue(110, line1, month4);

dataset.addValue(1000,line2,month1);
dataset.addValue(800, line2,month2);
dataset.addValue(600, line2,month3);
dataset.addValue(400, line2, month4);

//PlotOrientation plot = new PlotOrientation("VERTICAL");
JFreeChart jfc = ChartFactory.createBarChart
("Unbilled Milestones Dual Axis chart", // Title
"Month ", // X-Axis label
"No.of.Milestones", // Y-Axis label
dataset, // Dataset
PlotOrientation.VERTICAL, //Plot
true, // Show legend
true, // Show legend
true
);
jfc.setBackgroundPaint(bgColor);
final CategoryPlot plot = jfc.getCategoryPlot();
plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
plot.setDataset(1, dataset);
plot.mapDatasetToRangeAxis(1, 1);
final ValueAxis axis2 = new NumberAxis("Unbilled Amount");
plot.setRangeAxis(1, axis2);
plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
final BarRenderer renderer2 = new BarRenderer();
plot.setRenderer(1, renderer2);

final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

rangeAxis.setTickUnit(new NumberTickUnit(100));
rangeAxis.setLowerBound(0);
rangeAxis.setUpperBound(1500);

what i have to change to get two bars with two different axis values.

Awaiting for ur reply......


Regards,
Vairamuthu M

oacis
Posts: 101
Joined: Fri Jan 07, 2005 5:57 am
Location: Australia, Sydney

Post by oacis » Wed Aug 02, 2006 12:38 pm

Hello,

When I run your provided code (thank-you it makes it so much easier) I get 8 bars, all of which are stacked. Is this correct - how should it look?

vairamuthum
Posts: 9
Joined: Tue Jul 11, 2006 8:10 am
Location: Delhi
Contact:

Reply for the avove

Post by vairamuthum » Wed Aug 02, 2006 12:45 pm

Hi,
That is correct but did u find any overlapping there and both axis range changed based on the dataset values.That is my problem


Regards,
Vairamuthu M

oacis
Posts: 101
Joined: Fri Jan 07, 2005 5:57 am
Location: Australia, Sydney

Re: Reply for the avove

Post by oacis » Wed Aug 02, 2006 1:18 pm

vairamuthum wrote:Hi,
That is correct but did u find any overlapping there
Not quite sure what you mean about overlapping - I get a chart like the following:

Code: Select all


      +--+ 
      |  |
      |  |
      |  |
      |  |        +--+
      |  |        |  |
      +--+        |  |
      |  |        |  |
      |  |        +--+
      |  |        |  |
      |  |        |  |
+--+  |  |  +--+  |  |
|  |  |  |  |  |  |  |
+--+  |  |  +--+  |  |
|  |  |  |  |  |  |  |
|  |  |  |  |  |  |  |
+--+  +--+  +--+  +--+
Except there are eight bars rather than the four that I am showing (got bored with the ascii art).

... and both axis range changed based on the dataset values.
Once again, not quite sure what you mean - from my point of view, the ranges will change if the data changes...

vairamuthum
Posts: 9
Joined: Tue Jul 11, 2006 8:10 am
Location: Delhi
Contact:

How do u change x-axis and y-axis labels size and font type?

Post by vairamuthum » Tue Aug 08, 2006 6:45 am

Dear Dave and all,
I have created the bar chart but axis values ans labels are not looking good.I want to change the size of labels,axis values,their corresponding font sizes,types.

And one more i want to create dual axis chart using jsp implementing jfree.Just give me some suggestions to achieve this.........!

Awaiting for ur reply.......

Regards,
Vairamuthu M

oacis
Posts: 101
Joined: Fri Jan 07, 2005 5:57 am
Location: Australia, Sydney

Post by oacis » Tue Aug 08, 2006 12:38 pm

For
And one more i want to create dual axis chart using jsp implementing jfree.Just give me some suggestions to achieve this.........!
have you tried http://cewolf.sourceforge.net/

Locked