1
我想合併多個圖形來創建一個圖表。個別圖形具有白色背景,但不知何故,儘管使用setBackgroundpaint api,我的合併圖表最終變爲灰色背景。jfreechart setBackgroundpaint不工作
public static String mergeXYGraphs(List<XYPlot> plots, String title, boolean legend, int width, int height) throws IOException
{
if(plots != null && !plots.isEmpty())
{
XYPlot base = plots.get(0);
for(int i = 1; i< plots.size(); i++)
{
base.setDataset(i, plots.get(i).getDataset());
base.setRenderer(i, plots.get(i).getRenderer());
}
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, base, legend);
setDateAxis(base);
chart.getXYPlot().setBackgroundPaint(Color.WHITE);
return saveImageFile(chart, "merged", "charts", width, height);
}
return "";
}
private static void setDateAxis(XYPlot plot)
{
DateAxis domainAxis = new DateAxis();
domainAxis.setAutoTickUnitSelection(true);
domainAxis.setDateFormatOverride(new SimpleDateFormat("dd/MM"));
plot.setDomainAxis(domainAxis);
}
PS:base.setBackgroundPaint(Color.WHITE);無法正常工作或