To do the colors I subclass the BarRenderer and override the getItemPaint(...) method.
Once I do this, the code directly below which attempts to set the value labels does not work.. If I remove the code which sets my custom rendere, it then works again.
Could this be a bug? I'm using JFree 0.9.12
Code: Select all
// get plot
CategoryPlot categoryPlot = chart.getCategoryPlot();
// Create new instance of custom class to override getItemPaint() method
CustomHorizontalBarChartRenderer customBarRenderer = new CustomHorizontalBarChartRenderer();
// Set instance as new renderer.
categoryPlot.setRenderer(customBarRenderer);
Code: Select all
// Display the numeric values at the end of the bar.
CategoryItemRenderer itemRenderer = categoryPlot.getRenderer();
itemRenderer.setItemLabelsVisible(Boolean.TRUE);
itemRenderer.setItemLabelAnchor(ItemLabelAnchor.INSIDE12);
itemRenderer.setItemLabelTextAnchor(TextAnchor.CENTER_RIGHT);
itemRenderer.setItemLabelFont(chartSpec.getLabelFont());
Thanks for the help..
Jim