#920 Negative XYStackedAreaChart Wrong


When you try to create a XYStackedAreaChart which contains series with negative values the chart is wrong because the graph goes to zero in the middle of each value of the series.

E.G. if you have a value for x=2 of -5 and the rest of the series is zero you should have a graph that is zero in point x=1, zero in x=3 and -5 in x=2 however you obtain a graph that is zero in point x=1.5 and zero in x=3.5. that doesn't have sense because you haven't got values for the series at this points. Due to this error if you have more that one series the stacked area is calculated wrongly. And if you have series with values at the same point all negatives this creates holes in the graph and funny results.

Here is an example with two series:

DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries s1 = new XYSeries(1, true, false);
XYSeries s2 = new XYSeries(2, true, false);
XYSeries s3 = new XYSeries(3, true, false);

s1.add (0,0);
s1.add (1,-3);
s1.add (2,0);
s1.add (3,0);
s2.add (1,0);
s2.add (0,0);
s2.add (2,-4);
s2.add (3,0);
s3.add (1,0);
s3.add (0,0);
s3.add (2,-4);
s3.add (3,0);

final JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Network Throughput Per IP", // chart title
"Category", // domain axis label
"Value", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, false);


  • Noé Rodríguez González


    I have solved this problem. Here is a patch. I would be very happy if you contact me or check the patch and accept it and change the state of the Bug to solved.

    Noe A. Rodriguez Glez.



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

Sign up for the SourceForge newsletter:

No, thanks