我需要帮助来更改甘特图中百分比条的颜色。我正在使用动态报告 api 生成 pdf 格式的报告。
我需要更改进度条的颜色,它始终显示为绿色,我想更改它。
private JasperReportBuilder build(){
JasperReportBuilder report = DynamicReports.report();
TextColumnBuilder<String> uName = col.column("Name", "name", type.stringType()).setHorizontalAlignment(HorizontalAlignment.LEFT);
TextColumnBuilder<Date> uStart = col.column("Start", "start", type.dateType());
TextColumnBuilder<Date> uEnd = col.column("End", "end", type.dateType());
TextColumnBuilder<Double> uProgress = col.column("Progress", "progress", type.doubleType());
GanttChartBuilder chart2 = cht.ganttChart().customizers(new ChartCustomizer())
.setTask(uName)
.series(
cht.ganttSerie()
.setStartDate(uStart)
.setEndDate(uEnd)
.setPercent(uProgress)
).seriesColors(new Color(163,209,255)).setDataSource(createDataSourceForGanntChart(initiativeList,initiativeGroup,periodId,subPeriodId,fullPath,model))
.setTimeAxisFormat(
cht.axisFormat().setLabel(objectInitiativeChart.getCategoryLabel()))
.setTaskAxisFormat(
cht.axisFormat().setLabel(objectInitiativeChart.getSeriesLabel()));
report.summary(chart2);
return report;
}
private class ChartCustomizer implements DRIChartCustomizer, Serializable {
private static final long serialVersionUID = 1L;
@Override
public void customize(JFreeChart chart, ReportParameters reportParameters) {
BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();
renderer.setMaximumBarWidth(0.1);
org.jfree.chart.axis.CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
domainAxis.setCategoryMargin(-0.5d);
}
}