Menu

XY Chart with Double Y axis for common X axis

Help
ahlvarun
2006-06-27
2013-01-13
  • ahlvarun

    ahlvarun - 2006-06-27

    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

     
    • Zoltan Luspai

      Zoltan Luspai - 2006-06-27

      have a look at cewolfexample subproject; there are few examples for combined charts.

       
    • ahlvarun

      ahlvarun - 2006-06-28

      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

       
    • Zoltan Luspai

      Zoltan Luspai - 2006-07-04

      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

       

Log in to post a comment.