In Cuba Platform 6.5, how do you use the Chart Legend Listeners?

I was able to successfully get a PieChart Listener to function as described in the release notes
at (http://files.cuba-platform.com/cuba/release-notes/6.5/), but I’m struggling to get the Legend listeners to work.

I’m using these imports


import com.haulmont.charts.gui.components.charts.Chart;
import com.haulmont.charts.gui.components.charts.PieChart;

calling the code below:

private void updateCharts() {
    //Pie Chart
    pieChartsDs.clear();
    List<PieChartValues> pieChartList = applicationService.findArrayApplicationStatusCounts(null);
    for (PieChartValues pieChartValues : pieChartList) {
        pieChartsDs.includeItem(pieChartValues);
    }
    PieChart pieChart = (PieChart) chartPie;
    pieChart.setColors(TabColors.getColors());
    pieChart.setLabelsEnabled(true);
}

And the code for the event listeners are displayed in the attached file.

getItem

Hi,

Use getDataItem() or getEntity() method with Legend events:


pieChart.addLegendMarkerClickListener(event -> {
    PieChartValues item = (PieChartValues) event.getEntityNN();
});

See com.haulmont.charts.gui.components.charts.Chart.LegendItemEvent for details.

You can see all the available options from your IDE in auto completion popup (see attachment).

piechart-api