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

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

Introduction

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

Prototype

public void setUpperMargin(double margin) 

Source Link

Document

Sets the upper margin for the axis and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:org.bench4Q.console.ui.section.S_SummarizeSection.java

/**
 * @return//from  w  w  w  .  j ava2s  .  co m
 * @throws IOException
 */
public JPanel drawSessionPic() throws IOException {

    CategoryDataset dataset = getDataSet();
    JFreeChart chart = ChartFactory.createBarChart3D("Session", "Session type", "Session number", dataset,
            PlotOrientation.VERTICAL, true, true, true);
    CategoryPlot plot = chart.getCategoryPlot();
    org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.1);
    domainAxis.setUpperMargin(0.1);
    domainAxis.setCategoryLabelPositionOffset(10);
    domainAxis.setCategoryMargin(0.2);

    org.jfree.chart.axis.ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setUpperMargin(0.1);

    org.jfree.chart.renderer.category.BarRenderer3D renderer;
    renderer = new org.jfree.chart.renderer.category.BarRenderer3D();
    renderer.setBaseOutlinePaint(Color.red);
    renderer.setSeriesPaint(0, new Color(0, 255, 255));
    renderer.setSeriesOutlinePaint(0, Color.BLACK);
    renderer.setSeriesPaint(1, new Color(0, 255, 0));
    renderer.setSeriesOutlinePaint(1, Color.red);
    renderer.setItemMargin(0.1);

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setItemLabelFont(new Font("", Font.PLAIN, 12));
    renderer.setItemLabelPaint(Color.black);
    renderer.setItemLabelsVisible(true);
    plot.setRenderer(renderer);

    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setBackgroundPaint(Color.WHITE);

    return new ChartPanel(chart);
}

From source file:org.ow2.clif.jenkins.ClifProjectAction.java

private JFreeChart createActionErrorGraph(ClifGraphParam params) {
    DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> errorsDS = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();

    List<AbstractBuild> builds = new ArrayList<AbstractBuild>(getProject().getBuilds());
    Collections.sort(builds);/*www. j  a  va  2s.  c  o  m*/
    for (Run<?, ?> currentBuild : builds) {
        Result buildResult = currentBuild.getResult();
        if (buildResult != null && buildResult.isBetterOrEqualTo(Result.SUCCESS)) {
            ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(currentBuild);
            ClifBuildAction clifBuildAction = currentBuild.getAction(ClifBuildAction.class);
            if (clifBuildAction == null) {
                continue;
            }
            ClifReport clifReport = clifBuildAction.getReport();
            if (clifReport == null) {
                continue;
            }
            TestPlan tp = clifReport.getTestplan(params.getTestPlan());
            if (tp == null) {
                continue;
            }
            if (tp.getAggregatedMeasures() != null) {
                Measure m = tp.getAggregatedMeasure(params.getLabel());
                if (m == null) {
                    continue;
                }
                errorsDS.add(m.errorPercent() * 100, Messages.ProjectAction_Errors(), label);
            }
        }
    }

    final CategoryAxis xAxis = new CategoryAxis(Messages.ProjectAction_BuildAxis());
    xAxis.setLowerMargin(0.01);
    xAxis.setUpperMargin(0.01);
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    xAxis.setMaximumCategoryLabelLines(3);

    final ValueAxis errorsAxis = new NumberAxis(Messages.ProjectAction_ErrorAxis());
    errorsAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    errorsAxis.setUpperMargin(0.1);

    final LineAndShapeRenderer errorRenderer = new LineAndShapeRenderer();
    errorRenderer.setItemMargin(0.0);

    final CategoryPlot plot = new CategoryPlot(errorsDS.build(), xAxis, errorsAxis, errorRenderer);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    JFreeChart chart = new JFreeChart(Messages.ProjectAction_PercentageOfErrors(), plot);
    chart.setBackgroundPaint(Color.WHITE);

    return chart;
}

From source file:hudson.plugins.codeviation.RepositoryView.java

private JFreeChart createChart(CategoryDataset dataset, int max) {

    final JFreeChart chart = ChartFactory.createLineChart(null, // chart title
            null, // unused
            "counts", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );//w w  w  .j a v a2  s.  com

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    final LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    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.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();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperBound(max * 1.2);
    rangeAxis.setLowerBound(0);

    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setStroke(new BasicStroke(4.0f));

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

    return chart;
}

From source file:org.ow2.clif.jenkins.ClifProjectAction.java

private JFreeChart createActionGraph(ClifGraphParam params) {
    DefaultStatisticalCategoryDataset timeDS = new DefaultStatisticalCategoryDataset();
    DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> minmaxDS = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();

    List<AbstractBuild> builds = new ArrayList<AbstractBuild>(getProject().getBuilds());
    Collections.sort(builds);/*  ww  w  .  j av a2 s  .  com*/
    for (Run<?, ?> currentBuild : builds) {
        Result buildResult = currentBuild.getResult();
        if (buildResult != null && buildResult.isBetterOrEqualTo(Result.SUCCESS)) {
            ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(currentBuild);
            ClifBuildAction clifBuildAction = currentBuild.getAction(ClifBuildAction.class);
            if (clifBuildAction == null) {
                continue;
            }
            ClifReport clifReport = clifBuildAction.getReport();
            if (clifReport == null) {
                continue;
            }
            TestPlan tp = clifReport.getTestplan(params.getTestPlan());
            if (tp == null) {
                continue;
            }
            if (tp.getAggregatedMeasures() != null) {
                Measure m = tp.getAggregatedMeasure(params.getLabel());
                if (m == null) {
                    continue;
                }
                timeDS.add(m.getAverage(), m.getStdDev(), Messages.ProjectAction_Mean(), label);
                minmaxDS.add(m.getMax(), Messages.ProjectAction_Max(), label);
                minmaxDS.add(m.getMin(), Messages.ProjectAction_Min(), label);
            }
        }
    }

    final CategoryAxis xAxis = new CategoryAxis(Messages.ProjectAction_BuildAxis());
    xAxis.setLowerMargin(0.01);
    xAxis.setUpperMargin(0.01);
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    xAxis.setMaximumCategoryLabelLines(3);

    final ValueAxis timeAxis = new NumberAxis(Messages.ProjectAction_TimeAxis());
    timeAxis.setUpperMargin(0.1);
    // final ValueAxis minmaxTimeAxis = new NumberAxis("Time (ms)");
    final BarRenderer timeRenderer = new StatisticalBarRenderer();
    timeRenderer.setSeriesPaint(2, ColorPalette.RED);
    timeRenderer.setSeriesPaint(1, ColorPalette.YELLOW);
    timeRenderer.setSeriesPaint(0, ColorPalette.BLUE);
    timeRenderer.setItemMargin(0.0);

    final CategoryPlot plot = new CategoryPlot(timeDS, xAxis, timeAxis, timeRenderer);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    final CategoryItemRenderer minmaxRenderer = new LineAndShapeRenderer();
    // plot.setRangeAxis(1, timeAxis);
    plot.setDataset(1, minmaxDS.build());
    plot.mapDatasetToRangeAxis(1, 0);
    plot.setRenderer(1, minmaxRenderer);

    JFreeChart chart = new JFreeChart(params.getLabel(), plot);
    chart.setBackgroundPaint(Color.WHITE);

    return chart;
}

From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.HierarchicalBarChart.java

private void buildFinalChart(String title, String subTitle, String xAxisLabel, String yAxisLabel, int height,
        int width, String filename, Chart.Scale scaleMode, Chart.LegendFormat legendFormatMode, int alpha) {
    @SuppressWarnings("unchecked")
    Vector<Counter>[] vec = new Vector[this.timers.length];
    boolean exist;

    // create the dataset...
    for (int i = 0; i < this.timers.length; i++) {
        vec[i] = new Vector<Counter>();
        @SuppressWarnings("unchecked")
        Iterator<Element> it = this.timers[i].getDescendants();
        while (it.hasNext()) {
            try {
                Element elt = (Element) it.next();
                String name = elt.getAttributeValue("name");
                double value = Double.valueOf(elt.getAttributeValue("avg"));
                exist = false;/*from  w  ww.  ja  v a  2s.c  o  m*/
                for (int j = 0; j < vec[i].size(); j++) {
                    if (((Counter) vec[i].get(j)).getName().equals(name)) {
                        ((Counter) vec[i].get(j)).addValue(value);
                        exist = true;
                        break;
                    }
                }
                if (!exist) {
                    vec[i].add(new Counter(name, value));
                }
            } catch (ClassCastException e) {
                continue;
            }
        }
    }

    CategoryDataset dataset = null;
    try {
        dataset = DatasetUtilities.createCategoryDataset(toSeries(vec[0]), this.categories, toDataset(vec));
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        throw new IllegalArgumentException(
                "Benchmark names must have different names. Be sure that your filter contains correct timers names");
    }

    // create the chart...
    final CategoryAxis categoryAxis = new CategoryAxis(xAxisLabel);
    final ValueAxis valueAxis = new NumberAxis(yAxisLabel);

    final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, new HierarchicalBarRenderer());

    plot.setOrientation(PlotOrientation.VERTICAL);
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.addSubtitle(new TextTitle(subTitle));

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    final HierarchicalBarRenderer renderer = (HierarchicalBarRenderer) plot.getRenderer();

    renderer.setItemMargin(0.01);
    renderer.setDatasetTree(this.timers);
    renderer.setSeries(toSeries(vec[0]));
    renderer.setAlpha(alpha);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryMargin(HierarchicalBarChart.CATEGORY_MARGIN);
    domainAxis.setUpperMargin(0.05);
    domainAxis.setLowerMargin(0.05);

    try {
        if ((filename == null) || "".equals(filename)) {
            throw new RuntimeException(
                    "The output filename for the HierarchicalBarChart cannot be null or empty !");
        }

        ChartUtilities.saveChartAsPNG(XMLHelper.createFileWithDirs(filename + ".png"), chart, width, height);

        Utilities.saveChartAsSVG(chart, new Rectangle(width, height),
                XMLHelper.createFileWithDirs(filename + ".svg"));
    } catch (java.io.IOException e) {
        System.err.println("Error writing chart image to file");
        e.printStackTrace();
    }
}

From source file:com.thalesgroup.hudson.plugins.cccc.CcccChartBuilder.java

protected JFreeChart createGraph() {

    JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, "Number of modules",
            buildDataset(action), PlotOrientation.VERTICAL, true, false, true);

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);/*from  w w  w.  j a  v  a  2  s.c  o m*/
    plot.setForegroundAlpha(0.8f);
    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);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    CategoryItemRenderer firstRender = new DefaultCategoryItemRenderer();
    CcccAreaRenderer renderer = new CcccAreaRenderer(action.getUrlName());
    plot.setRenderer(firstRender);

    //Second
    NumberAxis axis2 = new NumberAxis("Lines of Code");
    axis2.setLabelPaint(Color.BLUE);
    axis2.setAxisLinePaint(Color.BLUE);
    axis2.setTickLabelPaint(Color.BLUE);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    categoryPlot.setRangeAxis(1, axis2);
    //CategoryAxis categoryAxis = categoryPlot.getDomainAxis();
    categoryPlot.setDataset(1, buildDataset2(action));
    categoryPlot.mapDatasetToRangeAxis(1, 1);
    CategoryItemRenderer rendu = new DefaultCategoryItemRenderer();
    rendu.setBasePaint(Color.BLUE);
    categoryPlot.setRenderer(1, rendu);

    //Third
    NumberAxis axis3 = new NumberAxis("McCabe's Cyclomatic Number");
    axis3.setLabelPaint(Color.GREEN);
    axis3.setAxisLinePaint(Color.GREEN);
    axis3.setTickLabelPaint(Color.GREEN);
    CategoryPlot categoryPlot3 = chart.getCategoryPlot();
    categoryPlot3.setRangeAxis(2, axis3);
    categoryPlot3.setDataset(2, buildDataset3(action));
    categoryPlot3.mapDatasetToRangeAxis(2, 2);
    categoryPlot3.mapDatasetToDomainAxis(2, 0);
    CategoryItemRenderer rendu3 = new DefaultCategoryItemRenderer();
    rendu3.setBasePaint(Color.GREEN);
    categoryPlot3.setRenderer(2, rendu3);

    return chart;
}

From source file:com.googlecode.refit.jenkins.ReFitGraph.java

/**
 * Creates a chart from the test result data set.
 * <p>//from www  .  ja va 2s  .c om
 * The i-th row of the data set corresponds to the results from the i-th build.
 * Each row has columns 0, 1, 2 containing the number of failed, skipped and passed tests.
 * The chart stacks these values from bottom to top, joins the values for the same columns
 * with lines and fills the areas between the lines with given colours.
 * <p> 
 * TODO Find out if Jenkins core provides any caching for the chart or the data set.
 */
@Override
protected JFreeChart createGraph() {

    final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart title
            null, // domain axis label 
            "count", // range axis label
            data, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    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(data, rangeAxis);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRange(true);

    StackedAreaRenderer ar = new StackedAreaRenderer2() {
        private static final long serialVersionUID = 1L;

        /**
         * Colour brush for the given data point.
         */
        @Override
        public Paint getItemPaint(int row, int column) {
            return super.getItemPaint(row, column);
        }

        /**
         * URL for the given data point, which gets opened when the user clicks on or near
         * the data point in the chart.
         */
        @Override
        public String generateURL(CategoryDataset dataset, int row, int column) {
            ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
            return label.getUrl();
        }

        /**
         * Tooltip to be displayed on the chart when the user hovers at or near the
         * data point.
         * <p>
         * The tooltip has the format {@code #17 : 300 Passed}, indicating the build number
         * and the number of tests with the given result.
         */
        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
            TestResult result = label.getResult();
            String rowKey = (String) dataset.getRowKey(row);
            return result.getOwner().getDisplayName() + " : " + dataset.getValue(row, column) + " "
                    + rowKey.substring(1);
        }
    };
    plot.setRenderer(ar);

    // Define colours for the data points by column index
    ar.setSeriesPaint(0, ColorPalette.RED); // Failed
    ar.setSeriesPaint(1, ColorPalette.YELLOW); // Skipped
    ar.setSeriesPaint(2, ColorPalette.BLUE); // Passed

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

    return chart;
}

From source file:hudson.model.LoadStatistics.java

/**
 * Creates a trend chart./*from   w ww . jav a  2 s .  co  m*/
 */
public JFreeChart createChart(CategoryDataset ds) {
    final JFreeChart chart = ChartFactory.createLineChart(null, // chart title
            null, // unused
            null, // range axis label
            ds, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseStroke(new BasicStroke(3));
    configureRenderer(renderer);

    final CategoryAxis domainAxis = new NoOverlapCategoryAxis(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();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

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

    return chart;
}

From source file:com.google.jenkins.flakyTestHandler.plugin.TestFlakyStatsOverRevision.java

private JFreeChart createChart(CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart title
            null, // unused
            "count", // range axis label*/master
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );//w w w. j a  va2 s  .  com

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    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();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    StackedAreaRenderer ar = new StackedAreaRenderer2() {

        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            RevisionLabel label = (RevisionLabel) dataset.getColumnKey(column);
            Number value = dataset.getValue(row, column);
            switch (row) {
            case 0:
                return label.revision + ": " + value + " fails";
            case 1:
                return label.revision + ": " + value + " passes";
            default:
                return label.revision;
            }
        }
    };
    plot.setRenderer(ar);
    ar.setSeriesPaint(0, ColorPalette.RED); // Fails.
    ar.setSeriesPaint(1, ColorPalette.BLUE); // Passes.

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

    return chart;
}

From source file:hudson.plugins.measurement_plots.Graph.java

protected org.jfree.chart.JFreeChart createGraph() {
    final org.jfree.data.category.CategoryDataset dataset = getDataSetBuilder().build();

    final org.jfree.chart.JFreeChart chart = org.jfree.chart.ChartFactory.createStackedAreaChart(title, // chart title
            null, // unused
            null, // range axis label
            dataset, // data
            org.jfree.chart.plot.PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );/*from www  .j ava2  s  .  c om*/

    chart.setBackgroundPaint(java.awt.Color.white);

    final org.jfree.chart.plot.CategoryPlot plot = chart.getCategoryPlot();

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

    org.jfree.chart.axis.CategoryAxis domainAxis = new hudson.util.ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(org.jfree.chart.axis.CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final org.jfree.chart.axis.NumberAxis rangeAxis = (org.jfree.chart.axis.NumberAxis) plot.getRangeAxis();
    hudson.util.ChartUtil.adjustChebyshev(dataset, rangeAxis);
    rangeAxis.setStandardTickUnits(org.jfree.chart.axis.NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRange(true);

    org.jfree.chart.renderer.category.StackedAreaRenderer areaRenderer = new hudson.util.StackedAreaRenderer2() {

        @Override
        public java.awt.Paint getItemPaint(int row, int column) {
            GraphLabel key = (GraphLabel) dataset.getColumnKey(column);
            if (key.getColor() != null) {
                return key.getColor();
            }
            return super.getItemPaint(row, column);
        }

        @Override
        public String generateURL(org.jfree.data.category.CategoryDataset dataset, int row, int column) {
            GraphLabel label = (GraphLabel) dataset.getColumnKey(column);
            return label.getUrl();
        }

        @Override
        public String generateToolTip(org.jfree.data.category.CategoryDataset dataset, int row, int column) {
            GraphLabel label = (GraphLabel) dataset.getColumnKey(column);
            return label.getToolTip();
        }
    };
    plot.setRenderer(areaRenderer);
    areaRenderer.setSeriesPaint(2, hudson.util.ColorPalette.BLUE);

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

    return chart;
}