图例颜色列表的?
解决方案 »
- 快来看看啊,时间非常紧急!!!
- 请教一个关于缓存的问题
- javamail的问题,弄不懂。
- 小问题:修改Integer
- 关于List的问题,一个List装了若干ObjectX,我想remove一个ObjectX.c=-1的对象,请问如何做?
- 数据提取问题!!?????
- 请教高手,一个非常简单的问题,呵呵呵,我好多分的
- JAVA应用程序的多语言支持,如输入框可以同时输入不同语言文字并正确显示,难!
- 我又来给大家送分来了,想提前致富的快来抢吧!
- “flush()清除缓冲区强迫输出”是什么意思?
- 代理模式与中间者模式的区别是?
- 希望哥哥姐姐高手们,帮帮我一个简单问题(Java表格table问题)、在线等-------谢谢
chart = ChartFactory.createPieChart("", data, false,
false, false); PiePlot pie = (PiePlot)chart.getPlot();
pie.setSectionPaint(0,new Color(255,255,0));//设置颜色(图例和饼上份额的颜色)
pie.setSectionPaint(1,new Color(255,0,255));
pie.setSectionPaint(2,new Color(255,0,0));
另外,像org.jfree.chart.plot.CategoryPlot
这个类理有如下方法,允许你自己设置图例:setFixedLegendItemspublic void setFixedLegendItems(LegendItemCollection items) Sets the fixed legend items for the plot. Leave this set to null if you prefer the legend items to be created automatically. Parameters:
items - the legend items (null permitted).
See Also:
getFixedLegendItems()
http://blog.chinaunix.net/u1/59153/showart_973391.html
还是比如柱状图的柱子的颜色?不是很清楚
http://www.jfree.org/jfreechart/
这是jfreechart的官网,里面有例子,也有API doc,楼主可以自己查一下,你想要的~~
public String createBarChart(CategoryDataset dataset, String xName, String yName,
String chartTitle, String chartName) {
JFreeChart chart = ChartFactory.createBarChart3D(chartTitle, // 图表标题
xName, // 目录轴的显示标签
yName, // 数值轴的显示标签
dataset, // 数据集
PlotOrientation.VERTICAL, // 图表方向:水平、垂直
true, // 是否显示图例(对于简单的柱状图必须是false)
true, // 是否生成工具
false // 是否生成URL链接
);
Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, FONT_SIZE);
chart.setTextAntiAlias(true);
// create plot
CategoryPlot plot = chart.getCategoryPlot();
chart.setBackgroundPaint(Color.white);
// 设置横虚线可见
plot.setRangeGridlinesVisible(true);
// 虚线色彩
plot.setRangeGridlinePaint(Color.gray);
// x轴设置
CategoryAxis domainAxis = plot.getDomainAxis();
// 轴标题
domainAxis.setLabelFont(labelFont);
domainAxis.setTickLabelPaint(Color.black); // 横轴下的字体颜色
// 轴数值
domainAxis.setTickLabelFont(labelFont);
domainAxis.setLabelPaint(Color.black); // 横轴主字体颜色 // 设置距离图片左端距离
domainAxis.setLowerMargin(BAR_POSITION);
// 设置距离图片右端距离
domainAxis.setUpperMargin(BAR_POSITION);
plot.setDomainAxis(domainAxis);
// 设置柱图背景色(注意,系统取色的时候要使用16位的模式来查看颜色编码,这样比较准确)
plot.setBackgroundPaint(new Color(BAR_BACK_RCOLOR, BAR_BACK_GCOLOR, BAR_BACK_BCOLOR));
NumberAxis numberaxis = (NumberAxis) plot.getRangeAxis();
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
numberaxis.setAutoRangeIncludesZero(true);
BarRenderer3D renderer = new BarRenderer3D();
// 设置柱子宽度
renderer.setMaximumBarWidth(BAR_WIDTH);
// 设置柱子高度
// renderer.setMinimumBarLength(0.2);
// 设置柱子边框颜色
// renderer.setBaseOutlinePaint(Color.BLACK);
// 设置柱子边框可见
// renderer.setDrawBarOutline(true); // 设置柱的颜色
renderer.setSeriesPaint(0, new Color(BAR_FRONT_RCOLOR, BAR_FRONT_GCOLOR, BAR_FRONT_BCOLOR)); // 设置每个地区所包含的平行柱的之间距离
// renderer.setItemMargin(0.0); // 显示每个柱的数值,并修改该数值的字体属性
renderer.setIncludeBaseInRange(true);
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setBaseItemLabelsVisible(true); plot.setRenderer(renderer);
// 设置柱的透明度
plot.setForegroundAlpha(1.0f);
// 生成图表
return makePicture(chart, chartName);
}
这是之前写的一个例子,但是不知道包不包含你想要的~~,仅供参考
String chartTitle, String chartName) {
JFreeChart chart = ChartFactory.createBarChart3D(chartTitle, // 图表标题
xName, // 目录轴的显示标签
yName, // 数值轴的显示标签
dataset, // 数据集
PlotOrientation.VERTICAL, // 图表方向:水平、垂直
true, // 是否显示图例(对于简单的柱状图必须是false)
true, // 是否生成工具
false // 是否生成URL链接
);
google都问了,但是没有相关的
plot.setBackgroundPaint(paintObject); // 实现Paint接口的对象都可以作为paintObject
比如Color(设置纯色)、GradientPaint(设置渐变)、TexturePaint(甚至是材质)等等