class ColorRenderer extends org.jfree.chart.renderer.category.StackedBarRenderer3D{
private Paint[] colors;
//初始化柱子颜色
private String[] colorValues = { "#FFFF32", "#FFCEEB"};
public ColorRenderer() {
colors = new Paint[colorValues.length];
for (int i = 0; i < colorValues.length; i++) {
colors[i] = Color.decode(colorValues[i]);
}
//Label的显示方式,没有Label可以没有
setDrawBarOutline(false);
setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
setBaseItemLabelsVisible(true);
setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
}
//每根柱子以初始化的颜色不断轮循
@Override
public Pain
JFreeChart对StackedBar的自定义颜色
最新推荐文章于 2024-11-21 09:59:30 发布