我生成一个透明的图表,可以通过它看到网页的背景。
到目前为止,我已经完成了这项工作(为简洁起见,省略了数据集的填充):
lineChartObject=ChartFactory.createLineChart("Title","Legend","Amount",line_chart_dataset,PlotOrientation.VERTICAL,true,true,false);
CategoryPlot p = lineChartObject.getCategoryPlot();
Color trans = new Color(0xFF, 0xFF, 0xFF, 0);
lineChartObject.setBackgroundPaint(trans);
p.setBackgroundPaint(trans);
for (int i=0;i<=3;i++){
lineChartObject.getCategoryPlot().getRenderer().setSeriesStroke(i, new BasicStroke(3.0f));
lineChartObject.getCategoryPlot().getRenderer().setBaseItemLabelsVisible(false);
}
提出这个:
我无法找到方法:
修改: X标签域是日期。
答案 0 :(得分:3)
对于(1)尝试:
plot.setOutlineVisible(false);
对于(2),沿x轴具有太多类别的常见原因是数据实际上是数字,在这种情况下,您应该使用XYPlot而不是CategoryPlot。使用XYPlot时,x轴刻度的调整方式与y轴的调整方式相同。
从OP编辑:使用带有TimeSeriesCollection的TimeSeriesChart作为XYDataSet完成了工作! (想说X域是日期)
对于(3)尝试:
LegendTitle legend = chart.getLegend();
legend.setFrame(BlockBorder.NONE);
legend.setBackgroundPaint(new Color(0, 0, 0, 0));