Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[FIXED JENKINS-9745] Added new graphs that shows the totals (scaled).
  • Loading branch information
uhafner committed Jun 17, 2011
1 parent 120a026 commit bdb83f404d546beef91857811d972bf98f74ae14
@@ -22,6 +22,7 @@
import hudson.plugins.analysis.graph.NewVersusFixedGraph;
import hudson.plugins.analysis.graph.NullGraph;
import hudson.plugins.analysis.graph.PriorityGraph;
import hudson.plugins.analysis.graph.TotalsGraph;
import hudson.plugins.analysis.graph.UserGraphConfigurationView;
import hudson.plugins.analysis.graph.GraphConfigurationView;
import hudson.plugins.analysis.graph.TrendDetails;
@@ -212,6 +213,7 @@ protected List<BuildResultGraph> getAvailableGraphs() {

availableGraphs.add(new NewVersusFixedGraph());
availableGraphs.add(new PriorityGraph());
availableGraphs.add(new TotalsGraph());
if (hasValidResults()) {
availableGraphs.add(new HealthGraph(getLastAction().getHealthDescriptor()));
}
@@ -1,5 +1,6 @@
package hudson.plugins.analysis.graph;

import java.awt.BasicStroke;
import java.awt.Color;
import java.util.Calendar;
import java.util.Collection;
@@ -18,6 +19,7 @@
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.data.category.CategoryDataset;
import org.joda.time.LocalDate;

@@ -487,5 +489,17 @@ public JFreeChart createBlockChart(final CategoryDataset dataset) {

return chart;
}

/**
* Creates a line renderer with predefined stroke.
*
* @return a line renderer
* @since 1.23
*/
protected CategoryItemRenderer createLineRenderer() {
LineAndShapeRenderer render = new LineAndShapeRenderer(true, false);
render.setBaseStroke(new BasicStroke(2.0f));
return render;
}
}

@@ -0,0 +1,76 @@
package hudson.plugins.analysis.graph;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.data.category.CategoryDataset;

import hudson.plugins.analysis.Messages;
import hudson.plugins.analysis.core.BuildResult;
import hudson.plugins.analysis.util.ToolTipProvider;

import hudson.util.ColorPalette;

/**
* Builds a graph showing the total of warnings in a scaled line graph.
*
* @author Ulli Hafner
* @since 1.23
*/
public class TotalsGraph extends CategoryBuildResultGraph {
@Override
public String getId() {
return "TOTALS";
}

@Override
public String getLabel() {
return Messages.Trend_type_totals();
}

@Override
protected List<Integer> computeSeries(final BuildResult current) {
List<Integer> series = new ArrayList<Integer>();
series.add(current.getNumberOfWarnings());
return series;
}

@Override
protected JFreeChart createChart(final CategoryDataset dataSet) {
NumberAxis numberAxis = new NumberAxis("count");
numberAxis.setAutoRange(true);
numberAxis.setAutoRangeIncludesZero(false);

CategoryAxis domainAxis = new CategoryAxis();
domainAxis.setCategoryMargin(0.0);

CategoryPlot plot = new CategoryPlot(dataSet, domainAxis, numberAxis, new LineAndShapeRenderer(true, false));
plot.setOrientation(PlotOrientation.VERTICAL);

JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.setBackgroundPaint(Color.white);

setCategoryPlotProperties(plot);

return chart;
}

@Override
protected Color[] getColors() {
return new Color[] {ColorPalette.BLUE};
}

@Override
protected CategoryItemRenderer createRenderer(final GraphConfiguration configuration, final String pluginName, final ToolTipProvider toolTipProvider) {
return createLineRenderer();
}
}

@@ -52,6 +52,7 @@ Trend.type.priority=Priority distribution of all warnings
Trend.type.fixed=Distribution of new and fixed warnings
Trend.type.difference=Difference between new and fixed warnings (cumulative)
Trend.type.health=Number of warnings colored according to the health report thresholds
Trend.type.totals=Total number of warnings

ResultAction.Status=Plug-in Result:

@@ -80,7 +80,7 @@ public Main(final BuildResultGraph graph) {
private BuildResult createResult(final int buildNumber, final int fixedWarnings, final int newWarnings) {
BuildResult result = mock(BuildResult.class);

when(result.getNumberOfWarnings()).thenReturn(newWarnings);
when(result.getNumberOfWarnings()).thenReturn(newWarnings + 1000);
when(result.getNumberOfAnnotations(Priority.HIGH)).thenReturn(newWarnings);
when(result.getNumberOfAnnotations(Priority.NORMAL)).thenReturn(fixedWarnings);
when(result.getNumberOfAnnotations(Priority.LOW)).thenReturn(Math.abs(newWarnings - fixedWarnings));
@@ -109,6 +109,7 @@ public static void main(final String[] args) {
availableGraphs.add(new NewVersusFixedGraph());
availableGraphs.add(new PriorityGraph());
availableGraphs.add(new DifferenceGraph());
availableGraphs.add(new TotalsGraph());

for (BuildResultGraph graph : availableGraphs) {
Main chart = new Main(graph);

0 comments on commit bdb83f4

Please sign in to comment.