Search in sources :

Example 6 with ShiftedCategoryAxis

use of hudson.util.ShiftedCategoryAxis in project jenkins by jenkinsci.

the class Job method getBuildTimeGraph.

public Graph getBuildTimeGraph() {
    return new Graph(getLastBuildTime(), 500, 400) {

        @Override
        protected JFreeChart createGraph() {
            DataSetBuilder<String, ChartLabel> data = new DataSetBuilder<>();
            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 = // chart
            ChartFactory.createStackedAreaChart(// chart
            null, // unused
            null, // range axis label
            Messages.Job_minutes(), // data
            dataset, // orientation
            PlotOrientation.VERTICAL, // include legend
            false, // tooltips
            true, // urls
            false);
            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.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 ChartLabelStackedAreaRenderer2(dataset);
            plot.setRenderer(ar);
            // crop extra space around the graph
            plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));
            return chart;
        }
    };
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) DataSetBuilder(hudson.util.DataSetBuilder) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot) StackedAreaRenderer(org.jfree.chart.renderer.category.StackedAreaRenderer) ShiftedCategoryAxis(hudson.util.ShiftedCategoryAxis) Graph(hudson.util.Graph) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ShiftedCategoryAxis(hudson.util.ShiftedCategoryAxis) CategoryDataset(org.jfree.data.category.CategoryDataset) RectangleInsets(org.jfree.ui.RectangleInsets)

Example 7 with ShiftedCategoryAxis

use of hudson.util.ShiftedCategoryAxis in project memory-map-plugin by Praqma.

the class MemoryMapBuildAction method createPairedBarCharts.

protected JFreeChart createPairedBarCharts(String title, String yAxis, double max, double min, CategoryDataset dataSet, Collection<ValueMarker> markers) {
    final CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    final NumberAxis rangeAxis = new NumberAxis(yAxis);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperBound(max);
    rangeAxis.setLowerBound(min);
    BarRenderer renderer = new BarRenderer();
    CategoryPlot plot = new CategoryPlot(dataSet, domainAxis, rangeAxis, renderer);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);
    for (ValueMarker mkr : markers) {
        plot.addRangeMarker(mkr);
    }
    JFreeChart chart = new JFreeChart(plot);
    chart.setTitle(title);
    return chart;
}
Also used : ShiftedCategoryAxis(hudson.util.ShiftedCategoryAxis) NumberAxis(org.jfree.chart.axis.NumberAxis) ShiftedCategoryAxis(hudson.util.ShiftedCategoryAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) ValueMarker(org.jfree.chart.plot.ValueMarker) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

ShiftedCategoryAxis (hudson.util.ShiftedCategoryAxis)7 JFreeChart (org.jfree.chart.JFreeChart)7 CategoryAxis (org.jfree.chart.axis.CategoryAxis)7 NumberAxis (org.jfree.chart.axis.NumberAxis)7 CategoryPlot (org.jfree.chart.plot.CategoryPlot)7 RectangleInsets (org.jfree.ui.RectangleInsets)4 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)3 StackedAreaRenderer (org.jfree.chart.renderer.category.StackedAreaRenderer)3 CategoryDataset (org.jfree.data.category.CategoryDataset)3 DataSetBuilder (hudson.util.DataSetBuilder)2 Graph (hudson.util.Graph)2 StackedAreaRenderer2 (hudson.util.StackedAreaRenderer2)2 LegendTitle (org.jfree.chart.title.LegendTitle)2 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)2 BasicStroke (java.awt.BasicStroke)1 JSONObject (net.sf.json.JSONObject)1 LogarithmicAxis (org.jfree.chart.axis.LogarithmicAxis)1 ValueMarker (org.jfree.chart.plot.ValueMarker)1 LineAndShapeRenderer (org.jfree.chart.renderer.category.LineAndShapeRenderer)1