Example usage for org.jfree.chart.axis CategoryAxis setCategoryMargin

List of usage examples for org.jfree.chart.axis CategoryAxis setCategoryMargin

Introduction

In this page you can find the example usage for org.jfree.chart.axis CategoryAxis setCategoryMargin.

Prototype

public void setCategoryMargin(double margin) 

Source Link

Document

Sets the category margin and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:hudson.model.Job.java

public Graph getBuildTimeGraph() {
    return new Graph(getLastBuildTime(), 500, 400) {
        @Override/*from  w w  w .  j  av a 2s .co m*/
        protected JFreeChart createGraph() {
            class ChartLabel implements Comparable<ChartLabel> {
                final Run run;

                public ChartLabel(Run r) {
                    this.run = r;
                }

                public int compareTo(ChartLabel that) {
                    return this.run.number - that.run.number;
                }

                @Override
                public boolean equals(Object o) {
                    // HUDSON-2682 workaround for Eclipse compilation bug
                    // on (c instanceof ChartLabel)
                    if (o == null || !ChartLabel.class.isAssignableFrom(o.getClass())) {
                        return false;
                    }
                    ChartLabel that = (ChartLabel) o;
                    return run == that.run;
                }

                public Color getColor() {
                    // TODO: consider gradation. See
                    // http://www.javadrive.jp/java2d/shape/index9.html
                    Result r = run.getResult();
                    if (r == Result.FAILURE)
                        return ColorPalette.RED;
                    else if (r == Result.UNSTABLE)
                        return ColorPalette.YELLOW;
                    else if (r == Result.ABORTED || r == Result.NOT_BUILT)
                        return ColorPalette.GREY;
                    else
                        return ColorPalette.BLUE;
                }

                @Override
                public int hashCode() {
                    return run.hashCode();
                }

                @Override
                public String toString() {
                    String l = run.getDisplayName();
                    if (run instanceof Build) {
                        String s = ((Build) run).getBuiltOnStr();
                        if (s != null)
                            l += ' ' + s;
                    }
                    return l;
                }

            }

            DataSetBuilder<String, ChartLabel> data = new DataSetBuilder<String, ChartLabel>();
            for (Run r : getNewBuilds()) {
                if (r.isBuilding())
                    continue;
                data.add(((double) r.getDuration()) / (1000 * 60), "min", new ChartLabel(r));
            }

            final CategoryDataset dataset = data.build();

            final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart
                    // title
                    null, // unused
                    Messages.Job_minutes(), // range axis label
                    dataset, // data
                    PlotOrientation.VERTICAL, // orientation
                    false, // include legend
                    true, // tooltips
                    false // urls
            );

            chart.setBackgroundPaint(Color.white);

            final CategoryPlot plot = chart.getCategoryPlot();

            // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
            plot.setBackgroundPaint(Color.WHITE);
            plot.setOutlinePaint(null);
            plot.setForegroundAlpha(0.8f);
            // plot.setDomainGridlinesVisible(true);
            // plot.setDomainGridlinePaint(Color.white);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.black);

            CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
            plot.setDomainAxis(domainAxis);
            domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
            domainAxis.setLowerMargin(0.0);
            domainAxis.setUpperMargin(0.0);
            domainAxis.setCategoryMargin(0.0);

            final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
            ChartUtil.adjustChebyshev(dataset, rangeAxis);
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

            StackedAreaRenderer ar = new StackedAreaRenderer2() {
                @Override
                public Paint getItemPaint(int row, int column) {
                    ChartLabel key = (ChartLabel) dataset.getColumnKey(column);
                    return key.getColor();
                }

                @Override
                public String generateURL(CategoryDataset dataset, int row, int column) {
                    ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
                    return String.valueOf(label.run.number);
                }

                @Override
                public String generateToolTip(CategoryDataset dataset, int row, int column) {
                    ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
                    return label.run.getDisplayName() + " : " + label.run.getDurationString();
                }
            };
            plot.setRenderer(ar);

            // crop extra space around the graph
            plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

            return chart;
        }
    };
}

From source file:edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo1.java

/**
 * Creates a sample chart.//from www  .  j ava 2 s .  c o  m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(BoxAndWhiskerCategoryDataset dataset) {

    CategoryAxis domainAxis = new CategoryAxis(null);
    NumberAxis rangeAxis = new NumberAxis(rangeLabel);
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);
    JFreeChart chart = new JFreeChart(chartTitle, plot);

    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    renderer.setLegendItemLabelGenerator(
            new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT));

    //RowCount -- serie count
    if (dataset.getColumnCount() * dataset.getRowCount() < 5) {

        domainAxis.setLowerMargin(0.2);
        domainAxis.setUpperMargin(0.2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(0.5);
        //   domainAxis.setCategoryMargin(domainAxis.getCategoryMargin()*2);
        /*         
        System.out.println("1lowerMargin="+domainAxis.getLowerMargin());
        System.out.println("ItemMargin="+renderer.getItemMargin());
        System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/

    }

    else if (dataset.getColumnCount() * dataset.getRowCount() < 10) {
        domainAxis.setLowerMargin(domainAxis.getLowerMargin() * 2);
        domainAxis.setUpperMargin(domainAxis.getUpperMargin() * 2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(renderer.getItemMargin() * 2);
        else
            domainAxis.setCategoryMargin(domainAxis.getCategoryMargin() * 2);

        /*System.out.println("2lowerMargin="+domainAxis.getLowerMargin());
        System.out.println("ItemMargin="+renderer.getItemMargin());
        System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/

    }

    if (legendPanelOn)
        chart.removeLegend();
    return chart;

}

From source file:org.toobsframework.pres.chart.ChartUtil.java

public static CategoryAxis createCategoryAxis(IRequest componentRequest, DomainAxisDef categoryAxisDef,
        Map params, boolean is3D) {
    CategoryAxis categoryAxis;
    if (is3D) {// ww w  .j  a v  a2  s . com
        categoryAxis = new CategoryAxis3D();
    } else {
        categoryAxis = new CategoryAxis();
    }
    if (categoryAxisDef != null) {
        if (categoryAxisDef.getDomainLabel() != null) {
            categoryAxis
                    .setLabel(evaluateTextLabel(componentRequest, categoryAxisDef.getDomainLabel(), params));
            if (categoryAxisDef.getDomainLabel().getFont() != null) {
                categoryAxis.setLabelFont(getFont(categoryAxisDef.getDomainLabel(), null));
            }
            categoryAxis.setLabelPaint(getColor(categoryAxisDef.getDomainLabel().getColor()));
        }

        if (categoryAxisDef.getLabelPosition() != null) {
            Integer labelPos = domainLabelPositions.get(ParameterUtil.resolveParam(componentRequest,
                    categoryAxisDef.getLabelPosition(), params, "standard")[0]);
            if (labelPos != null) {
                switch (labelPos) {
                case DOM_LABEL_STANDARD_TYPE:
                    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
                    break;
                case DOM_LABEL_UP_45_TYPE:
                    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
                    break;
                case DOM_LABEL_DOWN_45_TYPE:
                    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
                    break;
                case DOM_LABEL_UP_90_TYPE:
                    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
                    break;
                case DOM_LABEL_DOWN_90_TYPE:
                    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
                    break;
                }
            }
        }
        double domainMargin = Double.parseDouble(ParameterUtil.resolveParam(componentRequest,
                categoryAxisDef.getDomainMargin(), params, "0.0")[0]);
        double lowerMargin = Double.parseDouble(ParameterUtil.resolveParam(componentRequest,
                categoryAxisDef.getLowerMargin(), params, "0.0")[0]);
        double upperMargin = Double.parseDouble(ParameterUtil.resolveParam(componentRequest,
                categoryAxisDef.getUpperMargin(), params, "0.0")[0]);

        categoryAxis.setCategoryMargin(domainMargin);
        categoryAxis.setLowerMargin(lowerMargin);
        categoryAxis.setUpperMargin(upperMargin);
    }
    return categoryAxis;
}

From source file:edu.ucla.stat.SOCR.chart.ChartGenerator.java

private JFreeChart createBoxAndWhiskerChart(String title, String xLabel, String yLabel,
        BoxAndWhiskerCategoryDataset dataset) {

    CategoryAxis domainAxis = new CategoryAxis(xLabel);
    NumberAxis rangeAxis = new NumberAxis(yLabel);

    // CategoryItemRenderer renderer = new BoxAndWhiskerRenderer();
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);
    JFreeChart chart = new JFreeChart(title, plot);

    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    //columnCount -- category count
    //RowCount -- serie count
    if (dataset.getColumnCount() * dataset.getRowCount() < 5) {

        domainAxis.setLowerMargin(0.2);// w ww  .  j  a v  a 2 s  .  co  m
        domainAxis.setUpperMargin(0.2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(0.5);
        //   domainAxis.setCategoryMargin(domainAxis.getCategoryMargin()*2);

        /*   System.out.println("lowerMargin="+domainAxis.getLowerMargin());
           System.out.println("ItemMargin="+renderer.getItemMargin());
           System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/
    }

    else if (dataset.getColumnCount() * dataset.getRowCount() < 10) {
        domainAxis.setLowerMargin(domainAxis.getLowerMargin() * 2);
        domainAxis.setUpperMargin(domainAxis.getUpperMargin() * 2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(renderer.getItemMargin() * 2);
        else
            domainAxis.setCategoryMargin(domainAxis.getCategoryMargin() * 2);
        /*System.out.println("lowerMargin="+domainAxis.getLowerMargin());
         System.out.println("ItemMargin="+renderer.getItemMargin());
         System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());
        */
    }

    return chart;
}

From source file:edu.ucla.stat.SOCR.analyses.gui.Chart.java

private JFreeChart createBoxAndWhiskerChart(String title, String xLabel, String yLabel,
        BoxAndWhiskerCategoryDataset dataset) {

    CategoryAxis domainAxis = new CategoryAxis(xLabel);
    NumberAxis rangeAxis = new NumberAxis(yLabel);

    // CategoryItemRenderer renderer = new BoxAndWhiskerRenderer();
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);
    JFreeChart chart = new JFreeChart(title, plot);

    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    //columnCount -- category count
    //RowCount -- serie count
    if (dataset.getColumnCount() * dataset.getRowCount() < 5) {

        domainAxis.setLowerMargin(0.2);/*  ww w  . j  a v a2  s.  c  om*/
        domainAxis.setUpperMargin(0.2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(0.5);
        //   domainAxis.setCategoryMargin(domainAxis.getCategoryMargin()*2);

        //System.out.println("lowerMargin="+domainAxis.getLowerMargin());
        //System.out.println("ItemMargin="+renderer.getItemMargin());
        //System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());

    }

    else if (dataset.getColumnCount() * dataset.getRowCount() < 10) {
        domainAxis.setLowerMargin(domainAxis.getLowerMargin() * 2);
        domainAxis.setUpperMargin(domainAxis.getUpperMargin() * 2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(renderer.getItemMargin() * 2);
        else
            domainAxis.setCategoryMargin(domainAxis.getCategoryMargin() * 2);
        //System.out.println("lowerMargin="+domainAxis.getLowerMargin());
        //System.out.println("ItemMargin="+renderer.getItemMargin());
        //System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());

    }

    return chart;
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpression.java

protected void configureChart(final JFreeChart chart) {
    super.configureChart(chart);

    final CategoryPlot cpl = chart.getCategoryPlot();
    final CategoryItemRenderer renderer = cpl.getRenderer();
    if (StringUtils.isEmpty(getTooltipFormula()) == false) {
        renderer.setBaseToolTipGenerator(
                new FormulaCategoryTooltipGenerator(getRuntime(), getTooltipFormula()));
    }//from   ww w  .j  a  va  2  s  . c o  m
    if (StringUtils.isEmpty(getUrlFormula()) == false) {
        renderer.setBaseItemURLGenerator(new FormulaCategoryURLGenerator(getRuntime(), getUrlFormula()));
    }
    if (this.categoricalLabelFormat != null) {
        final StandardCategoryItemLabelGenerator scilg;
        if (categoricalLabelDecimalFormat != null) {
            final DecimalFormat numFormat = new DecimalFormat(categoricalLabelDecimalFormat,
                    new DecimalFormatSymbols(getRuntime().getResourceBundleFactory().getLocale()));
            numFormat.setRoundingMode(RoundingMode.HALF_UP);
            scilg = new StandardCategoryItemLabelGenerator(categoricalLabelFormat, numFormat);
        } else if (categoricalLabelDateFormat != null) {
            scilg = new StandardCategoryItemLabelGenerator(categoricalLabelFormat, new SimpleDateFormat(
                    categoricalLabelDateFormat, getRuntime().getResourceBundleFactory().getLocale()));
        } else {
            final DecimalFormat formatter = new DecimalFormat();
            formatter.setDecimalFormatSymbols(
                    new DecimalFormatSymbols(getRuntime().getResourceBundleFactory().getLocale()));
            scilg = new StandardCategoryItemLabelGenerator(categoricalLabelFormat, formatter);
        }
        renderer.setBaseItemLabelGenerator(scilg);
    }
    renderer.setBaseItemLabelsVisible(Boolean.TRUE.equals(getItemsLabelVisible()));
    if (getItemLabelFont() != null) {
        renderer.setBaseItemLabelFont(getItemLabelFont());
    }

    if (categoricalItemLabelRotation != null) {
        final ItemLabelPosition orgPosItemLabelPos = renderer.getBasePositiveItemLabelPosition();
        if (orgPosItemLabelPos == null) {
            final ItemLabelPosition pos2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                    TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, categoricalItemLabelRotation.doubleValue());
            renderer.setBasePositiveItemLabelPosition(pos2);
        } else {
            final ItemLabelPosition pos2 = new ItemLabelPosition(orgPosItemLabelPos.getItemLabelAnchor(),
                    orgPosItemLabelPos.getTextAnchor(), orgPosItemLabelPos.getRotationAnchor(),
                    categoricalItemLabelRotation.doubleValue());
            renderer.setBasePositiveItemLabelPosition(pos2);
        }

        final ItemLabelPosition orgNegItemLabelPos = renderer.getBaseNegativeItemLabelPosition();
        if (orgNegItemLabelPos == null) {
            final ItemLabelPosition pos2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                    TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, categoricalItemLabelRotation.doubleValue());
            renderer.setBaseNegativeItemLabelPosition(pos2);
        } else {
            final ItemLabelPosition neg2 = new ItemLabelPosition(orgNegItemLabelPos.getItemLabelAnchor(),
                    orgNegItemLabelPos.getTextAnchor(), orgNegItemLabelPos.getRotationAnchor(),
                    categoricalItemLabelRotation.doubleValue());
            renderer.setBaseNegativeItemLabelPosition(neg2);
        }
    }

    final Font labelFont = Font.decode(getLabelFont());

    final CategoryAxis categoryAxis = cpl.getDomainAxis();
    categoryAxis.setLabelFont(labelFont);
    categoryAxis.setTickLabelFont(labelFont);
    if (getCategoryTitleFont() != null) {
        categoryAxis.setLabelFont(getCategoryTitleFont());
    }
    if (getCategoryTickFont() != null) {
        categoryAxis.setTickLabelFont(getCategoryTickFont());
    }

    if (maxCategoryLabelWidthRatio != null) {
        categoryAxis.setMaximumCategoryLabelWidthRatio(maxCategoryLabelWidthRatio.floatValue());
    }
    cpl.setDomainGridlinesVisible(showGridlines);
    if (labelRotation != null) {
        double angle = labelRotation.doubleValue();
        CategoryLabelPosition top = createUpRotationCategoryLabelPosition(PlaneDirection.TOP, angle);
        CategoryLabelPosition bottom = createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM, angle);
        CategoryLabelPosition left = createUpRotationCategoryLabelPosition(PlaneDirection.LEFT, angle);
        CategoryLabelPosition right = createUpRotationCategoryLabelPosition(PlaneDirection.RIGHT, angle);
        CategoryLabelPositions rotationLabelPositions = new CategoryLabelPositions(top, bottom, left, right);
        categoryAxis.setCategoryLabelPositions(rotationLabelPositions);
    }

    final String[] colors = getSeriesColor();
    for (int i = 0; i < colors.length; i++) {
        renderer.setSeriesPaint(i, parseColorFromString(colors[i]));
    }

    if (lowerMargin != null) {
        categoryAxis.setLowerMargin(lowerMargin.doubleValue());
    }
    if (upperMargin != null) {
        categoryAxis.setUpperMargin(upperMargin.doubleValue());
    }
    if (categoryMargin != null) {
        categoryAxis.setCategoryMargin(categoryMargin.doubleValue());
    }

    configureRangeAxis(cpl, labelFont);
}

From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java

private JFreeChart createBoxAndWhiskerChart(String title, String xLabel, String yLabel,
        BoxAndWhiskerCategoryDataset dataset) {

    CategoryAxis domainAxis = new CategoryAxis(xLabel);
    NumberAxis rangeAxis = new NumberAxis(yLabel);

    // CategoryItemRenderer renderer = new BoxAndWhiskerRenderer();
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);
    JFreeChart chart = new JFreeChart(title, plot);

    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    //columnCount -- category count
    //RowCount -- serie count
    if (dataset.getColumnCount() * dataset.getRowCount() < 5) {

        domainAxis.setLowerMargin(0.2);/*www.ja  v a  2  s.co m*/
        domainAxis.setUpperMargin(0.2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(0.5);
        //   domainAxis.setCategoryMargin(domainAxis.getCategoryMargin()*2);

    }

    else if (dataset.getColumnCount() * dataset.getRowCount() < 10) {
        domainAxis.setLowerMargin(domainAxis.getLowerMargin() * 2);
        domainAxis.setUpperMargin(domainAxis.getUpperMargin() * 2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(renderer.getItemMargin() * 2);
        else
            domainAxis.setCategoryMargin(domainAxis.getCategoryMargin() * 2);
    }

    return chart;
}

From source file:org.jfree.chart.ChartFactory.java

/**
 * Creates an area chart with default settings.  The chart object returned
 * by this method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
 * range axis, and an {@link AreaRenderer} as the renderer.
 *
 * @param title  the chart title ({@code null} permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           ({@code null} permitted).
 * @param valueAxisLabel  the label for the value axis ({@code null}
 *                        permitted)./*from  ww  w  . j a va  2 s .  c o m*/
 * @param dataset  the dataset for the chart ({@code null} permitted).
 *
 * @return An area chart.
 */
public static JFreeChart createAreaChart(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    categoryAxis.setCategoryMargin(0.0);

    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    AreaRenderer renderer = new AreaRenderer();
    renderer.setDefaultToolTipGenerator(new StandardCategoryToolTipGenerator());

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    JFreeChart chart = new JFreeChart(title, plot);
    currentTheme.apply(chart);
    return chart;

}

From source file:org.jfree.chart.ChartFactory.java

/**
 * Creates a stacked area chart with default settings.  The chart object
 * returned by this method uses a {@link CategoryPlot} instance as the
 * plot, with a {@link CategoryAxis} for the domain axis, a
 * {@link NumberAxis} as the range axis, and a {@link StackedAreaRenderer}
 * as the renderer.//  w  ww .j  av  a 2  s  . c om
 *
 * @param title  the chart title ({@code null} permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           ({@code null} permitted).
 * @param valueAxisLabel  the label for the value axis ({@code null}
 *                        permitted).
 * @param dataset  the dataset for the chart ({@code null} permitted).
 *
 * @return A stacked area chart.
 */
public static JFreeChart createStackedAreaChart(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    categoryAxis.setCategoryMargin(0.0);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    StackedAreaRenderer renderer = new StackedAreaRenderer();
    renderer.setDefaultToolTipGenerator(new StandardCategoryToolTipGenerator());

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    JFreeChart chart = new JFreeChart(title, plot);
    currentTheme.apply(chart);
    return chart;

}