我想在我的jfreechart PieChart3D中更改饼图"碎片"的颜色,这是呈现饼图的代码:
<% response.setContentType("image/png"); %><%@page import="org.jfree.data.general.*"%><%@page import="org.jfree.chart.*"%><%@page import="org.jfree.chart.plot.*"%><%@page import="java.awt.Color" %><%
DefaultPieDataset ds = (DefaultPieDataset)session.getAttribute("usagePieOutputDataset");
JFreeChart chart = ChartFactory.createPieChart3D
(
null, // Title
ds, // Dataset
false, // Show legend
false, // Use tooltips
false // Configure chart to generate URLs?
);
chart.setBackgroundPaint(Color.WHITE);
chart.setBorderVisible(false);
PiePlot3D plot = ( PiePlot3D )chart.getPlot();
plot.setDepthFactor(0.0);
plot.setLabelGenerator(null); //null means no labels
plot.setLabelOutlinePaint(Color.LIGHT_GRAY);
plot.setLabelFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 10));
ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, 150, 144);
%>
Run Code Online (Sandbox Code Playgroud)
任何帮助都非常感谢.
每个部分的颜色通常填充在绘图的DrawingSupplier中.但是,您可以通过调用覆盖默认值
PiePlot.setSectionPaint(Comparable key, Paint paint);
Run Code Online (Sandbox Code Playgroud)
但是,您需要手动设置每个部分.如果您只想要一组不同的颜色,看起来您可以实现DrawingSupplier.
| 归档时间: |
|
| 查看次数: |
9502 次 |
| 最近记录: |