XYChart Overlay

  • Bruce Pascal

    Bruce Pascal - 2006-01-30

    Is there a way to plot two XY graphs using the XYChart and ChartPostProcessor? When I use overlaidchart the X values always start from zero so  I was thinking the CPP might resolve this issue. Any help would be greatly appreciated.


    • Brian Fox

      Brian Fox - 2006-01-31

      Bruce, I remember this problem but not the solution. Is this the problem with the axis always starting at 0? If so, in your postprocessor, you can change the axis range as needed.

    • Bruce Pascal

      Bruce Pascal - 2006-01-31

      Hi Brian,

      Thanks for the reply. Do you happen to remember how to change the axis range in the CPP? I'm still in the learning phase...


    • Brian Fox

      Brian Fox - 2006-02-07

      Here's an example of getting and setting range things:
        public void processChart( Object chart, Map params )
          //call to super
            super.processChart(chart, params);

            JFreeChart jfc = (JFreeChart) chart;

          //  StandardLegend sl = (StandardLegend) jfc.getLegend();
          //  Font font = sl.getItemFont();
          //  float newsize = font.getSize() -1;
          //  sl.setItemFont(font.deriveFont(newsize));
            //    with our combined chart, the data set is null, we have to get the sub
            // plots
            if ( jfc.getXYPlot() instanceof CombinedDomainXYPlot )
              List subplots = ((CombinedDomainXYPlot) jfc.getXYPlot()).getSubplots();

              int j = 0;
              for (Iterator i = subplots.iterator(); i.hasNext(); j++)
                XYPlot plot = (XYPlot) i.next();
                plot.getRangeAxis().setRange(new Range(1, 3));

                StandardXYItemRenderer rr = new StandardXYItemRenderer();
                for (int k = 0; k < 6; k++)
                  rr.setSeriesShape(k, getShape(j, k));
                  rr.setSeriesPaint(k, getColor(j, k));

            //do some different rendering
          catch (Exception e)

    • Bruce Pascal

      Bruce Pascal - 2006-02-09

      Hi Brian,
      Thanks very nuch for the reply. I think I've got it now. The working code:

      ChartPostProcessor combinedPP = new ChartPostProcessor()

          public void processChart(Object chartobj, Map params)
               JFreeChart chart = (JFreeChart) chartobj;
               XYPlot xyp = chart.getXYPlot();
              ValueAxis xrangeAxis = xyp.getDomainAxis();


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks