XYAreaChart with the Average

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jesusmgmarin
Posts: 13
Joined: Thu Apr 20, 2006 2:24 pm
Location: Spain
Contact:

XYAreaChart with the Average

Post by jesusmgmarin » Fri Jul 07, 2006 5:08 pm

Hello again...
Now I want to make a XYAreaChart. When I do it, the "dividing horizontal line" that there is, is in value 0 of the Y-axis , It would be possible to force to that it was another value instead of the 0?
(for example, in my case I would like that the "dividing line" was in the value of the Average)

I have proven with the example code:

Code: Select all

        final XYSeries series1 = new XYSeries("Random 1");
        series1.add(new Integer(1), new Double(500.2));
        series1.add(new Integer(2), new Double(694.1));
        series1.add(new Integer(3), new Double(-734.4));
        series1.add(new Integer(4), new Double(453.2));
        series1.add(new Integer(5), new Double(500.2));
        series1.add(new Integer(6), new Double(300.7));
        series1.add(new Integer(7), new Double(734.4));
        series1.add(new Integer(8), new Double(453.2));

        final XYSeriesCollection dataset = new XYSeriesCollection(series1);
		
		final JFreeChart chart = ChartFactory.createXYAreaChart(
            "XY Area Chart Demo",
            "Domain (X)", "Range (Y)",
            dataset,
            PlotOrientation.VERTICAL,
            true,  // legend
            true,  // tool tips
            false  // URLs
        );
        chart.setBackgroundPaint(Color.white);
        final XYPlot plot = chart.getXYPlot();
        //plot.setOutlinePaint(Color.black);
        plot.setBackgroundPaint(Color.lightGray);
        plot.setForegroundAlpha(0.65f);
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
        final ValueAxis domainAxis = plot.getDomainAxis();
        domainAxis.setTickMarkPaint(Color.black);
        domainAxis.setLowerMargin(0.0);
        domainAxis.setUpperMargin(0.0);
        final ValueAxis rangeAxis = plot.getRangeAxis();
        rangeAxis.setTickMarkPaint(Color.black);
	return chart;    

Locked