Search in sources :

Example 1 with NoOverlapCategoryAxis

use of hudson.util.NoOverlapCategoryAxis in project hudson-2.x by hudson.

the class LoadStatistics method createChart.

/**
     * Creates a trend chart.
     */
public JFreeChart createChart(CategoryDataset ds) {
    final JFreeChart chart = // chart title
    ChartFactory.createLineChart(// chart title
    null, // unused
    null, // range axis label
    null, // data
    ds, // orientation
    PlotOrientation.VERTICAL, // include legend
    true, // tooltips
    true, // urls
    false);
    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;
}
Also used : LineAndShapeRenderer(org.jfree.chart.renderer.category.LineAndShapeRenderer) NumberAxis(org.jfree.chart.axis.NumberAxis) NoOverlapCategoryAxis(hudson.util.NoOverlapCategoryAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) RectangleInsets(org.jfree.ui.RectangleInsets) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot) NoOverlapCategoryAxis(hudson.util.NoOverlapCategoryAxis)

Aggregations

NoOverlapCategoryAxis (hudson.util.NoOverlapCategoryAxis)1 JFreeChart (org.jfree.chart.JFreeChart)1 CategoryAxis (org.jfree.chart.axis.CategoryAxis)1 NumberAxis (org.jfree.chart.axis.NumberAxis)1 CategoryPlot (org.jfree.chart.plot.CategoryPlot)1 LineAndShapeRenderer (org.jfree.chart.renderer.category.LineAndShapeRenderer)1 RectangleInsets (org.jfree.ui.RectangleInsets)1