Skip to content
Permalink
Browse files

JENKINS-16787: add shape and center plot for single-build-graphs

  • Loading branch information...
mheinzerling committed Dec 5, 2014
1 parent eb29267 commit 6a41ae880af0a22eac3906676063e9c32035fe2e
Binary file not shown.
@@ -305,14 +305,15 @@ public CoverageGraphLayout color(Color color)
return Collections.unmodifiableList(plots);
}

public void apply(JFreeChart chart)
public void apply(JFreeChart chart, boolean onlyOneBuild)
{
final CategoryPlot plot = chart.getCategoryPlot();
Map<Axis, Integer> axisIds = new HashMap<>();
int axisId = 0;
for (Axis axis : axes)
{
LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false);
LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, onlyOneBuild);
if (onlyOneBuild) renderer.setUseOutlinePaint(true);
renderer.setBaseStroke(new BasicStroke(baseStroke));
//add axis layout here
plot.setRenderer(axisId, renderer);
@@ -470,6 +470,7 @@ protected JFreeChart createGraph() {
dataSets.put(e.getKey(), e.getValue().build());
}
List<Axis> axes = new ArrayList<>(dataSets.keySet());
boolean onlyOneBuild = dataSets.entrySet().iterator().next().getValue().getColumnCount() < 2;

final JFreeChart chart = ChartFactory.createLineChart(
null, // chart title
@@ -487,7 +488,7 @@ protected JFreeChart createGraph() {
CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
plot.setDomainAxis(domainAxis);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
domainAxis.setLowerMargin(0.0);
domainAxis.setLowerMargin(onlyOneBuild ? 0.5 : 0.0);
domainAxis.setUpperMargin(0.0);
domainAxis.setCategoryMargin(0.0);

@@ -504,7 +505,7 @@ protected JFreeChart createGraph() {
axisId++;
}

layout.apply(chart);
layout.apply(chart, onlyOneBuild);
return chart;
}

@@ -73,6 +73,19 @@ public void simpleLineCoverage() throws IOException
assertGraph(chart, "simple.png");
}

@Test
public void singeBuildCoverage() throws IOException
{
CoverageGraphLayout layout = new CoverageGraphLayout()
.plot().type(CoverageType.LINE).value(CoverageValue.MISSED).color(Color.RED)
.plot().type(CoverageType.LINE).value(CoverageValue.COVERED).color(Color.GREEN);

TestCoverageObject t = new TestCoverageObject().branch(6, 30).line(5000, 19000);
ctl.replay();
JFreeChart chart = t.createGraph(new GregorianCalendar(), WIDTH, HEIGHT, layout).getGraph();
assertGraph(chart, "singleBuild.png");
}

@Test
public void baseStroke() throws IOException
{

0 comments on commit 6a41ae8

Please sign in to comment.
You can’t perform that action at this time.