I am trying to make a chart with common X axis (a Time Field )data and two Y axis in the same graph, one of left hand side (Population for country X)and other on right hand side(Population for country Y).
Can anybody help me regarding what DataSet i should be using for this.
A small snippet of code will be of immense help.
regards
varun
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to make a chart with common X axis (a Time Field )data and two Y axis in the same graph, one of left hand side (Population for country X)and other on right hand side(Birth rate for country X).
Can anybody help me regarding what DataSet i should be using for this.
regards
varun
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You will need to use either a combined or overlaid chart. See the cewolf examples for the meaning of each type.
To add an extra axis to your chart you can add it with a post-processor. The post processor is to customize the look of your chart. Within that you will needs something like:
ChartPostProcessor dataColor = new ChartPostProcessor() {
public void processChart(Object chart, Map params) {
CategoryPlot plot = (CategoryPlot) ((JFreeChart) chart).getPlot();
NumberAxis axis = new NumberAxis("label");
plot.setRangeAxis(1, axis);
plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
}
So by setting the 1st axis you will add a new axist to the chart. Be warned this is just a rough example, I would recommend to get support about charts on jfreechart forums, or get the source for the jfree demos, which contains lots of such examples, here: http://www.jfree.org/jfreechart/jfreechart-1.0.0-demo.jnlp
Cheers,
Zoltan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi
I am trying to make a chart with common X axis (a Time Field )data and two Y axis in the same graph, one of left hand side (Population for country X)and other on right hand side(Population for country Y).
Can anybody help me regarding what DataSet i should be using for this.
A small snippet of code will be of immense help.
regards
varun
have a look at cewolfexample subproject; there are few examples for combined charts.
hi
i put up a wrong example last time. READ THIS:-
I am trying to make a chart with common X axis (a Time Field )data and two Y axis in the same graph, one of left hand side (Population for country X)and other on right hand side(Birth rate for country X).
Can anybody help me regarding what DataSet i should be using for this.
regards
varun
Hi,
You will need to use either a combined or overlaid chart. See the cewolf examples for the meaning of each type.
To add an extra axis to your chart you can add it with a post-processor. The post processor is to customize the look of your chart. Within that you will needs something like:
ChartPostProcessor dataColor = new ChartPostProcessor() {
public void processChart(Object chart, Map params) {
CategoryPlot plot = (CategoryPlot) ((JFreeChart) chart).getPlot();
NumberAxis axis = new NumberAxis("label");
plot.setRangeAxis(1, axis);
plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
}
So by setting the 1st axis you will add a new axist to the chart. Be warned this is just a rough example, I would recommend to get support about charts on jfreechart forums, or get the source for the jfree demos, which contains lots of such examples, here: http://www.jfree.org/jfreechart/jfreechart-1.0.0-demo.jnlp
Cheers,
Zoltan