Jfree chart Find Subplot

You can get a List of subplots using getSubplots(). To learn which subplot was clicked, examine the ChartMouseEvent that was sent from the ChartPanel, as suggested here.

Addendum: Here’s a simple implementation of ChartMouseListener that will show each ChartEntity as it is clicked.

ChartPanel panel = ...
panel.addChartMouseListener(new ChartMouseListener() {

    @Override
    public void chartMouseClicked(ChartMouseEvent e) {
        System.out.println(e.getEntity().getClass());
    }

    @Override
    public void chartMouseMoved(ChartMouseEvent event) {}
});

Leave a Comment