Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Vaadin charts scatter plot setExtremes() calls for yAxis can cause NPE.
Hello,
We noticed that code that we used for custom zooming (it used to be problematic to use zoom with multiple y-axis) stopped working:
case ZOOM:
scatterChart.getConfiguration().getyAxes().getAxes().stream()
.forEach(a->a.setExtremes(yStart,yEnd));
scatterChart.getConfiguration().getxAxis().setExtremes(xStart, xEnd);
causes NullPointerException as setExtremes function depends on the com.vaadin.addon.charts.model.Configuration.getAxisDimension(Axis axis) which has check that cannot work for Yaxis:
private short getAxisDimension(Axis axis) {
if (xAxis.contains(axis)) { <-- this will fail with NPE since we called getyAxes()...
return ChartClientRpc.X_AXIS;
} else if (yAxis.contains(axis)) {
return ChartClientRpc.Y_AXIS;
} else if (zAxis.getAxes().contains(axis)) {
return ChartClientRpc.Z_AXIS;
} else if (colorAxis.getAxes().contains(axis)) {
return ChartClientRpc.COLOR_AXIS;
} else {
return -1;
}
}
Edit:
It turns out that reordering of the calls fixes this problem as xAxis is initialized in such case, this works:
case ZOOM:
scatterChart.getConfiguration().getxAxis().setExtremes(xStart, xEnd);
scatterChart.getConfiguration().getyAxes().getAxes().stream()
.forEach(a->a.setExtremes(yStart,yEnd));
Still, it's probably a bug that should be fixed.
Thanks
Thanks Krzysztof for reporting this
You're definitely right, this seems to be a bug, I've created the issue #20263 in https://dev.vaadin.com/ .