@Test void shouldCreateLineChartWithDuplicateColors() { ToolsTrendChart chart = new ToolsTrendChart(); int availableColors = Palette.values().length; List<BuildResult<AnalysisBuildResult>> results = new ArrayList<>(); for (int i = 0; i < (availableColors + 1); i++) { results.add(createResult(i, Integer.toString(i), 1)); } LinesChartModel model = chart.create(results, new ChartModelConfiguration()); List<String> lineColors = new ArrayList<>(); for (LineSeries lineSeries : model.getSeries()) { lineColors.add(lineSeries.getItemStyle().getColor()); } boolean modelHasDuplicateColors = hasDuplicates(lineColors); assertThat(modelHasDuplicateColors).isTrue(); }
@Override public LinesChartModel create(final Iterable<? extends BuildResult<AnalysisBuildResult>> results, final ChartModelConfiguration configuration) { ToolSeriesBuilder builder = new ToolSeriesBuilder(); LinesDataSet lineModel = builder.createDataSet(configuration, results); LinesChartModel model = new LinesChartModel(); Palette[] colors = Palette.values(); int index = 0; for (String name : lineModel.getDataSetIds()) { LineSeries lineSeries = new LineSeries(name, colors[index++].getNormal(), StackedMode.SEPARATE_LINES, FilledMode.LINES); if (index == colors.length) { index = 0; } lineSeries.addAll(lineModel.getSeries(name)); model.addSeries(lineSeries); } model.setDomainAxisLabels(lineModel.getDomainAxisLabels()); return model; }
ToolsTrendChart implements TrendChart { @Override public LinesChartModel create(final Iterable<? extends BuildResult<AnalysisBuildResult>> results, final ChartModelConfiguration configuration) { ToolSeriesBuilder builder = new ToolSeriesBuilder(); LinesDataSet lineModel = builder.createDataSet(configuration, results); LinesChartModel model = new LinesChartModel(); Palette[] colors = Palette.values(); int index = 0; for (String name : lineModel.getDataSetIds()) { LineSeries lineSeries = new LineSeries(name, colors[index++].getNormal(), StackedMode.SEPARATE_LINES, FilledMode.LINES); if (index == colors.length) { index = 0; } lineSeries.addAll(lineModel.getSeries(name)); model.addSeries(lineSeries); } model.setDomainAxisLabels(lineModel.getDomainAxisLabels()); return model; } }
ToolsTrendChart implements TrendChart { @Override public LinesChartModel create(final Iterable<? extends BuildResult<AnalysisBuildResult>> results, final ChartModelConfiguration configuration) { ToolSeriesBuilder builder = new ToolSeriesBuilder(); LinesDataSet lineModel = builder.createDataSet(configuration, results); LinesChartModel model = new LinesChartModel(); Palette[] colors = Palette.values(); int index = 0; for (String name : lineModel.getDataSetIds()) { LineSeries lineSeries = new LineSeries(name, colors[index++].getNormal(), StackedMode.SEPARATE_LINES, FilledMode.LINES); if (index == colors.length) { index = 0; } lineSeries.addAll(lineModel.getSeries(name)); model.addSeries(lineSeries); } model.setDomainAxisLabels(lineModel.getDomainAxisLabels()); return model; }  }
ToolsTrendChart implements TrendChart { @Override public LinesChartModel create(final Iterable<? extends BuildResult<AnalysisBuildResult>> results, final ChartModelConfiguration configuration) { ToolSeriesBuilder builder = new ToolSeriesBuilder(); LinesDataSet lineModel = builder.createDataSet(configuration, results); LinesChartModel model = new LinesChartModel(); Palette[] colors = Palette.values(); int index = 0; for (String name : lineModel.getDataSetIds()) { LineSeries lineSeries = new LineSeries(name, colors[index++].getNormal(), StackedMode.SEPARATE_LINES, FilledMode.LINES); if (index == colors.length) { index = 0; } lineSeries.addAll(lineModel.getSeries(name)); model.addSeries(lineSeries); } model.setDomainAxisLabels(lineModel.getDomainAxisLabels()); return model; }  @Override LinesChartModel create(final Iterable<? extends BuildResult<AnalysisBuildResult>> results,
            final ChartModelConfiguration configuration); }
ToolsTrendChart implements TrendChart { @Override public LinesChartModel create(final Iterable<? extends BuildResult<AnalysisBuildResult>> results, final ChartModelConfiguration configuration) { ToolSeriesBuilder builder = new ToolSeriesBuilder(); LinesDataSet lineModel = builder.createDataSet(configuration, results); LinesChartModel model = new LinesChartModel(); Palette[] colors = Palette.values(); int index = 0; for (String name : lineModel.getDataSetIds()) { LineSeries lineSeries = new LineSeries(name, colors[index++].getNormal(), StackedMode.SEPARATE_LINES, FilledMode.LINES); if (index == colors.length) { index = 0; } lineSeries.addAll(lineModel.getSeries(name)); model.addSeries(lineSeries); } model.setDomainAxisLabels(lineModel.getDomainAxisLabels()); return model; }  @Override LinesChartModel create(final Iterable<? extends BuildResult<AnalysisBuildResult>> results,
            final ChartModelConfiguration configuration);  }