I am creating a Bar Chart:
final JFreeChart result = ChartFactory.createBarChart(TITLE, // chart title
X_TITLE, // domain axis label
Y_TITLE, // range axis label
dataset, // data
PlotOrientation.HORIZONTAL, // the plot orientation
true, // legend
true, // tooltips
false // urls
);
I then added a ChartMouseListener as described here.
When I click on a legend item, “LegendItemEntity: seriesKey=null, dataset=null” is displayed.
How do I access the legend text for the corresponding item?
Starting from
org.jfree.chart.demo.BarChartDemo1and adding the sameChartMouseListenerto the source yields results like this:If you’re geting a different result, an sscce may help.