Is there anyway to add an event listner for drill down events on Vaadin charts? I can see there is the method addChartDrillupListener(ChartDrillupListener) but no corresponding addChartDrilldownListener.
We basically need to know when a user drill’s down, and to get the series data for the “drilled down” level. The closest I can get is:
chart.addPointClickListener(event -> {
final DataSeries ds = (DataSeries) event.getSeries();
final DataSeriesItem dataSeriesItem2 = ds.get(event.getPointIndex());
System.out.println(ds);
System.out.println(dataSeriesItem2);
System.out.println(dataSeriesItem2.getX());
System.out.println(dataSeriesItem2.getY());
});
Unfortunately this only gives me the top level data series, and I can see no way of getting the child series from the parent series.
In addition, I would like to change the color of the bars (Column with Multilevel Drilldown). Is any of this possible?
I think you can do it like that:
chart.setDrilldownCallback(new DrilldownCallback() {
@Override public Series handleDrilldown(DrilldownEvent event) {
return getPointDrilldown(event.getItem());
}
});
In the DrilldownEvent you can get series on drilldown appeared.
Thanks for your reply, I’d seen that you can use a callback via. an async drilldown and grab the data there which solved 1 of the problems.
The other problem is that I can’t change the color of a column when it’s clicked. I’ve got the following code, but it doesn’t change the colour of the clicked on column, and I see a “data is undefined” error in the js console:
[code]
chart.addPointClickListener(event → {
final DataSeries series = (DataSeries) event.getSeries();
final DataSeriesItem item = series.get(event.getPointIndex());
// change the colour
item.setColor(SolidColor.CORAL);
// let the chart know it's updated
series.setConfiguration(chart.getConfiguration());
series.update(item);
});
[/code]Normally this should work in Highcharts, is this a bug in the Vaadin add-on library?
I also tried:
[code]
chart.addPointClickListener(event → {
final DataSeries series = (DataSeries) event.getSeries();
final DataSeriesItem item = series.get(event.getPointIndex());