在 JFreeChart 中我用来生成图表类别数据集与创建折线图。这看起来像这样:
Due to some axis changes I had to switch to XYLineAndShapeRenderer, and now the chart looks like this:
请注意图表周围的灰色区域。我想将其更改为透明或至少白色,就像上面的旧版本一样。
我尝试这样做:
chart.getPlot().setBackgroundPaint(Color.WHITE);
但这不起作用。
我怎样才能将背景更改为白色,并将绘图的背景更改为灰色(就像旧的一样?)
Thanks!
UPDATE
我可以更新绘图的背景,但不能更新图表面板的背景。
这是具有以下选项的图表:
lineChart.getPlot().setBackgroundPaint(Color.red);
chartPanel.setBackground(Color.yellow);
这里我想将黄色作为图表面板的背景。
这是一个用户错误。绘图周围的灰色区域不是ChartPanel
但是JFreeChart
本身。图表和绘图背景可以单独设置,例如:
lineChart.setBackgroundPaint(Color.pink);
plot.setBackgroundPaint(Color.cyan.darker());
完整的测试示例可见here https://stackoverflow.com/q/57633234/230513.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)