Creating an area graph below the XYDifference (Renderer) graph

I am trying last week to find a way to get JFreeChart to display something similar to the image below. Basically you look at three series (top, middle, bottom) with filling in between. And beneath it there is a (light green) fill color or area chart, as some might call it - it makes no sense, just for looks.

enter image description here

The only thing I miss in what I came up with is the last part: the fill at the bottom / area chart:

enter image description here

XYDifferenceRenderer Areachart, isachart, . . , , XYDifferenceRenderer. XYDifferenceRenderer - JFree, . , - , "" ( JFreeChart)?

+1
1

, , .

,

    • one -
    • - - . , plot.getRangeAxis().getLowerBound()
  • , . , .
  • ""

- , Paint :

static void addFill(Plot plot) {

    XYSeries lowerLimitSeries = ((XYSeriesCollection) (plot.getDataset())).getSeries(1);
    XYSeriesCollection fillSet = new XYSeriesCollection();
    double lowerBound = plot.getRangeAxis().getLowerBound();
    fillSet.addSeries(lowerLimitSeries);
    fillSet.addSeries(createLowerFillSeries(lowerLimitSeries, lowerBound));
    plot.setDataset(1, fillSet);
    Paint fillPaint = Color.GREEN;
    XYDifferenceRenderer fillRenderer = new XYDifferenceRenderer(fillPaint, fillPaint, false);
    fillRenderer.setSeriesStroke(0, new BasicStroke(0)); //do not show
    fillRenderer.setSeriesStroke(1, new BasicStroke(0)); //do not show
    plot.setRenderer(1, fillRenderer);
    ...
}

static XYSeries createLowerFillSeries(XYSeries lowerLimitSeries, double lowerLimit) {
    int size = lowerLimitSeries.getItems().size();
    XYSeries res = new XYSeries("lowerFillSeries");
    for (int i = 0; i < size; i++) res.add(new XYDataItem(lowerLimitSeries.getX(i), lowerLimit));
    return res;
}
+2

All Articles