Bar Chart (stacked) - How to hide labels if they equal zero

[code]from org.jfree.chart.labels import StandardCategoryItemLabelGenerator

class myLabelGenerator(StandardCategoryItemLabelGenerator):
def generateLabel(self,dataset,series, category):
value = dataset.getValue(series,category)
if value == 0:
return None
else:
return str(int(value))

chart = event.source.parent.getComponent(‘Bar Chart’).getChart()
plot = chart.getPlot()
renderer = plot.getRenderer()
renderer.setItemLabelGenerator(myLabelGenerator())
renderer.setItemLabelsVisible(True)[/code]

3 Likes