JFreechart生成柱状图,怎么更改柱子的颜色
我用JFreechart生成了张柱状图(JFreeChartchart=ChartFactory.createBarChart3D(......)),如下所示,默认颜色是...
我用JFreechart生成了张柱状图(JFreeChart chart = ChartFactory.createBarChart3D(......)),如下所示,
默认颜色是红色,怎么将红色更改,变成别的颜色,或者自己设定的颜色。
谢谢,大侠!!! 展开
默认颜色是红色,怎么将红色更改,变成别的颜色,或者自己设定的颜色。
谢谢,大侠!!! 展开
1个回答
推荐于2016-05-20
展开全部
CategoryPlot plot = (CategoryPlot) chart.getCategoryPlot();
BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
//设定柱子上面的颜色
customBarRenderer.setSeriesPaint(0, Color.decode("#24F4DB")); // 给series1 Bar
customBarRenderer.setSeriesPaint(1, Color.decode("#7979FF")); // 给series2 Bar
customBarRenderer.setSeriesPaint(2, Color.decode("#FF5555")); // 给series3 Bar
customBarRenderer.setSeriesPaint(3, Color.decode("#F8D661")); // 给series4 Bar
customBarRenderer.setSeriesPaint(4, Color.decode("#F284DC")); // 给series5 Bar
customBarRenderer.setSeriesPaint(5, Color.decode("#00BF00")); // 给series6 Bar
customBarRenderer.setSeriesOutlinePaint(0,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(1,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(2,Color.BLACK); //边框为黑色
customBarRenderer.setSeriesOutlinePaint(3,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(4,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(5,Color.BLACK); //边框为黑色
BarRenderer3D customBarRenderer = (BarRenderer3D) plot.getRenderer();
//设定柱子上面的颜色
customBarRenderer.setSeriesPaint(0, Color.decode("#24F4DB")); // 给series1 Bar
customBarRenderer.setSeriesPaint(1, Color.decode("#7979FF")); // 给series2 Bar
customBarRenderer.setSeriesPaint(2, Color.decode("#FF5555")); // 给series3 Bar
customBarRenderer.setSeriesPaint(3, Color.decode("#F8D661")); // 给series4 Bar
customBarRenderer.setSeriesPaint(4, Color.decode("#F284DC")); // 给series5 Bar
customBarRenderer.setSeriesPaint(5, Color.decode("#00BF00")); // 给series6 Bar
customBarRenderer.setSeriesOutlinePaint(0,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(1,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(2,Color.BLACK); //边框为黑色
customBarRenderer.setSeriesOutlinePaint(3,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(4,Color.BLACK);//边框为黑色
customBarRenderer.setSeriesOutlinePaint(5,Color.BLACK); //边框为黑色
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询