Search in sources :

Example 1 with NumberOnlyBuildLabel

use of hudson.util.ChartUtil.NumberOnlyBuildLabel in project hudson-2.x by hudson.

the class AbstractTestResultAction method buildDataSet.

private CategoryDataset buildDataSet(StaplerRequest req) {
    boolean failureOnly = Boolean.valueOf(req.getParameter("failureOnly"));
    DataSetBuilder<String, NumberOnlyBuildLabel> dsb = new DataSetBuilder<String, NumberOnlyBuildLabel>();
    for (AbstractTestResultAction<?> a = this; a != null; a = a.getPreviousResult(AbstractTestResultAction.class)) {
        dsb.add(a.getFailCount(), "failed", new NumberOnlyBuildLabel(a.owner));
        if (!failureOnly) {
            dsb.add(a.getSkipCount(), "skipped", new NumberOnlyBuildLabel(a.owner));
            dsb.add(a.getTotalCount() - a.getFailCount() - a.getSkipCount(), "total", new NumberOnlyBuildLabel(a.owner));
        }
    }
    return dsb.build();
}
Also used : NumberOnlyBuildLabel(hudson.util.ChartUtil.NumberOnlyBuildLabel)

Example 2 with NumberOnlyBuildLabel

use of hudson.util.ChartUtil.NumberOnlyBuildLabel in project hudson-2.x by hudson.

the class AbstractTestResultAction method createChart.

private JFreeChart createChart(StaplerRequest req, CategoryDataset dataset) {
    final String relPath = getRelPath(req);
    final JFreeChart chart = ChartFactory.createStackedAreaChart(// chart title
    null, // unused
    null, // range axis label
    "count", // data
    dataset, // orientation
    PlotOrientation.VERTICAL, // include legend
    false, // tooltips
    true, // urls
    false);
    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    // set the background color for the chart...
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //        legend.setAnchor(StandardLegend.SOUTH);
    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();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    StackedAreaRenderer ar = new StackedAreaRenderer2() {

        @Override
        public String generateURL(CategoryDataset dataset, int row, int column) {
            NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
            return relPath + label.build.getNumber() + "/testReport/";
        }

        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
            AbstractTestResultAction a = label.build.getAction(AbstractTestResultAction.class);
            switch(row) {
                case 0:
                    return String.valueOf(Messages.AbstractTestResultAction_fail(label.build.getDisplayName(), a.getFailCount()));
                case 1:
                    return String.valueOf(Messages.AbstractTestResultAction_skip(label.build.getDisplayName(), a.getSkipCount()));
                default:
                    return String.valueOf(Messages.AbstractTestResultAction_test(label.build.getDisplayName(), a.getTotalCount()));
            }
        }
    };
    plot.setRenderer(ar);
    // Failures.
    ar.setSeriesPaint(0, ColorPalette.RED);
    // Skips.
    ar.setSeriesPaint(1, ColorPalette.YELLOW);
    // Total.
    ar.setSeriesPaint(2, ColorPalette.BLUE);
    // 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) NumberOnlyBuildLabel(hudson.util.ChartUtil.NumberOnlyBuildLabel) CategoryAxis(org.jfree.chart.axis.CategoryAxis) CategoryDataset(org.jfree.data.category.CategoryDataset) RectangleInsets(org.jfree.ui.RectangleInsets) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot) StackedAreaRenderer(org.jfree.chart.renderer.category.StackedAreaRenderer)

Example 3 with NumberOnlyBuildLabel

use of hudson.util.ChartUtil.NumberOnlyBuildLabel in project violations-plugin by jenkinsci.

the class SeverityTypeDataSet method buildDataSet.

/**
     * Build the data set.
     *
     * @return the dataset.
     */
public CategoryDataset buildDataSet() {
    DataSetBuilder<Row, NumberOnlyBuildLabel> builder = new DataSetBuilder<Row, NumberOnlyBuildLabel>();
    for (ViolationsReport r = report; r != null; r = r.previous()) {
        if (r.getTypeSummaries() == null) {
            continue;
        }
        TypeSummary t = r.getTypeSummaries().get(type);
        if (t == null) {
            // Old report
            continue;
        }
        if (t.getSeverityArray() == null || t.getSeverityArray().length != Severity.NUMBER_SEVERITIES) {
            // Old report
            continue;
        }
        int[] nums = t.getSeverityArray();
        builder.add(nums[Severity.MEDIUM_VALUE] + nums[Severity.MEDIUM_HIGH_VALUE] + nums[Severity.MEDIUM_LOW_VALUE], MEDIUM_ROW, new NumberOnlyBuildLabel((Run) r.getBuild()));
        builder.add(nums[Severity.HIGH_VALUE], HIGH_ROW, new NumberOnlyBuildLabel((Run) r.getBuild()));
        builder.add(nums[Severity.LOW_VALUE], LOW_ROW, new NumberOnlyBuildLabel((Run) r.getBuild()));
    }
    return builder.build();
}
Also used : NumberOnlyBuildLabel(hudson.util.ChartUtil.NumberOnlyBuildLabel) DataSetBuilder(hudson.util.DataSetBuilder) ViolationsReport(hudson.plugins.violations.ViolationsReport) Run(hudson.model.Run) TypeSummary(hudson.plugins.violations.TypeSummary)

Aggregations

NumberOnlyBuildLabel (hudson.util.ChartUtil.NumberOnlyBuildLabel)3 Run (hudson.model.Run)1 TypeSummary (hudson.plugins.violations.TypeSummary)1 ViolationsReport (hudson.plugins.violations.ViolationsReport)1 DataSetBuilder (hudson.util.DataSetBuilder)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 StackedAreaRenderer (org.jfree.chart.renderer.category.StackedAreaRenderer)1 CategoryDataset (org.jfree.data.category.CategoryDataset)1 RectangleInsets (org.jfree.ui.RectangleInsets)1