I’m using a chart component that’s using the category bar renderer and bar style. The graph is set up in the horizontal orientation. What I’d like to be able to do is to move the value labels that show up on the top of the bars by default in this orientation to the right side of the bars. I haven’t been able to find any option within the chart customizer options to do this, and I’m guessing there’s probably a way to do this in the configureChart event script. Any ideas? Here’s a screenshot of what I’m trying to do.
Nevermind I was able to figure it out with some more digging. Here’s the configureChart event script and the end result for others that need it
from org.jfree.chart.labels import ItemLabelPosition
from org.jfree.chart.labels import ItemLabelAnchor
from org.jfree.ui import TextAnchor
plot = chart.getPlot()
renderer = plot.getRenderer()
renderer.setBasePositiveItemLabelPosition(ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT))
I’ve come up with another question related to this chart. When all of my data values are 0, the X axis is centered at 0 with negative values on the left and positive on the right. For this particular graph I’m counting defects, and there never any negative values. I’ve found that if I deselect the “Auto Range” property on my Y-Axis (my chart orientation is horizontal), then the X-axis is oriented correctly but it of course won’t auto range like I’d like it to. Is there a way to position it so that even with no data the X-axis starts at 0 while still being able to auto range?
Brian,
I’m trying to implement some similar code to configure a vertical bar chart’s labels, and I am having no luck.
Is there additional code needed to push the labels to the chart or trigger the script?
Here is my current script:
def configureChart(self, chart):
from org.jfree.chart.labels import ItemLabelPosition
from org.jfree.chart.labels import ItemLabelAnchor
from org.jfree.ui import TextAnchor
plot = chart.getPlot()
renderer = plot.getRenderer()
renderer.setBasePositiveItemLabelPosition(ItemLabelPosition())
Cheers!