Series in Stacked Chart Area with continuous outline

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
raunakkathuria
Posts: 16
Joined: Wed Dec 22, 2010 5:35 pm
antibot: No, of course not.
Location: India
Contact:

Series in Stacked Chart Area with continuous outline

Post by raunakkathuria » Mon Jan 03, 2011 7:10 am

Hi

I need to make the stacked area chart as continuous as shown below:

http://www.raunakkathuria.com/images/jf ... achart.jpg

what i have actually done is

http://www.raunakkathuria.com/images/jf ... _chart.jpg

I tried setting the series outline but by default XYAreaRenderer2 has outline visible as false, the below code snapshot from JFreeChart Api depicts that:

Code: Select all

 public XYAreaRenderer2(XYToolTipGenerator labelGenerator,
                           XYURLGenerator urlGenerator) {
        super();
       this.showOutline = false;  // set to false by default
        setBaseToolTipGenerator(labelGenerator);
        setURLGenerator(urlGenerator);
        GeneralPath area = new GeneralPath();
        area.moveTo(0.0f, -4.0f);
        area.lineTo(3.0f, -2.0f);
        area.lineTo(4.0f, 4.0f);
        area.lineTo(-4.0f, 4.0f);
        area.lineTo(-3.0f, -2.0f);
        area.closePath();
        this.legendArea = area;
    }
I override the class with my own class making outline as true:

Code: Select all

 public ExtendedXYAreaRenderer2(XYToolTipGenerator labelGenerator,
                           XYURLGenerator urlGenerator) {
        super();
        this.showOutline = true; // made it to true
        setBaseToolTipGenerator(labelGenerator);
        setURLGenerator(urlGenerator);
        GeneralPath area = new GeneralPath();
        area.moveTo(0.0f, -4.0f);
        area.lineTo(3.0f, -2.0f);
        area.lineTo(4.0f, 4.0f);
        area.lineTo(-4.0f, 4.0f);
        area.lineTo(-3.0f, -2.0f);
        area.closePath();
        this.legendArea = area;
    }
and used the following to set the series outline paint and stroke

Code: Select all

..... 
XYPlot xyplot = (XYPlot) chart.getPlot();
XYItemRenderer render = xyplot.getRenderer();
....

render.setBaseOutlinePaint(new Color(222, 222, 194));
render.setBaseOutlineStroke(new BasicStroke(2f));

render.setSeriesOutlinePaint(0, new Color(0, 0, 0));
render.setSeriesOutlineStroke(0, new BasicStroke(1.5f));
render.setSeriesOutlinePaint(1, new Color(51, 51, 51));
render.setSeriesOutlineStroke(1, new BasicStroke(1.5f));
render.setSeriesOutlinePaint(2, new Color(104, 104, 104));
render.setSeriesOutlineStroke(2, new BasicStroke(1.5f));

But I am not able to see any outline for series.

Is there any other method or any other way through which this can be accomplished.

Thanks & Regards
Raunak Kathuria

Locked