难以更改JFreeChart的背景颜色 [英] Difficulty Changing background colour of JFreeChart
本文介绍了难以更改JFreeChart的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将背景色更改为我的条形图,到目前为止似乎没有任何作用
这是我的下面的代码:
JFreeChart expbarchart = ChartFactory.createBarChart(每月支出",支出类型",金额(£)",barexp,PlotOrientation.VERTICAL,false,true,false);ChartPanel expframe =新的ChartPanel(expbarchart);expframe.setLocation(695,49);expframe.setSize(641,500);expframe.setBorder(new EtchedBorder(EtchedBorder.LOWERED,new Color(173,216,230),null));graphpanel.add(expframe);
我尝试做 .setbackground()
,但它似乎不起作用
谢谢
解决方案
StandardChartTheme主题=新的StandardChartTheme("JFree/Shadow",true);颜色=新颜色(173,216,230);theme.setPlotBackgroundPaint(color);theme.setChartBackgroundPaint(color.brighter());ChartFactory.setChartTheme(theme);
Im trying to change the background color to my bar chart and so far nothing seems to be working
Here is my code below:
JFreeChart expbarchart = ChartFactory.createBarChart("Monthly Expenditures", "Expenditure Type", "Amount (£)", barexp, PlotOrientation.VERTICAL, false, true, false);
ChartPanel expframe = new ChartPanel(expbarchart);
expframe.setLocation(695, 49);
expframe.setSize(641,500);
expframe.setBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(173, 216, 230), null));
graphpanel.add(expframe);
I have tried doing .setbackground()
and it does not seem to work
Thanks
解决方案
BarChartDemo1
shows you how to set the chart background paint:
chart.setBackgroundPaint(new Color(173, 216, 230));
It also shows you how to set a ChartTheme
that you can change:
StandardChartTheme theme = new StandardChartTheme("JFree/Shadow", true);
Color color = new Color(173, 216, 230);
theme.setPlotBackgroundPaint(color);
theme.setChartBackgroundPaint(color.brighter());
ChartFactory.setChartTheme(theme);
这篇关于难以更改JFreeChart的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文