protected JFreeChart createGraph()

in src/main/java/org/jenkinsci/plugins/awsdevicefarm/AWSDeviceFarmGraph.java [72:109]


    protected JFreeChart createGraph() {
        // Create chart.
        JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, yLabel, dataset, PlotOrientation.VERTICAL, true, true, false);
        chart.setBackgroundPaint(Color.WHITE);

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

        // Create chart plot.
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setForegroundAlpha(0.7f);
        plot.setBackgroundPaint(Color.WHITE);
        plot.setRangeGridlinePaint(Color.darkGray);

        // Create domain (x) axis.
        CategoryAxis domain = new ShiftedCategoryAxis(xLabel);
        domain.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
        domain.setLowerMargin(0.0);
        domain.setUpperMargin(0.0);
        domain.setCategoryMargin(0.0);
        plot.setDomainAxis(domain);

        // Create range (y) axis.
        NumberAxis range = (NumberAxis) plot.getRangeAxis();
        range.setAutoRange(true);
        range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

        // Create renderer and paint the chart.
        CategoryItemRenderer renderer = plot.getRenderer();
        plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0));

        // Set chart colors for sections.
        for (int i = 0; i < colors.length; i++) {
            renderer.setSeriesPaint(i, colors[i]);
        }
        return chart;
    }