jfreechart-fx
jfreechart-fx copied to clipboard
CrosshairOverlayFX NPE with CombinedDomainXYPlot
It seems that CrosshairOverlayFX
currently doesn't support CombinedDomainXYPlot
. When you add it as an overlay (viewer.canvas.addOverlay(crosshair)
) it will issue a NPE because it's unable to find a valid plot instance here:
https://github.com/jfree/jfreechart-fx/blob/83d824cc0b3b4f6481e74500ce9690f3157368ee/src/main/java/org/jfree/chart/fx/overlay/CrosshairOverlayFX.java#L67
A potential solution is to let CrosshairOverlayFX
accept the right plot in the constructor. In this case, and I'm not sure the best way to account for this, you'll also need to update the yy
value computation (e.g. for vertical combined plots) so that the crosshair shows at the right height:
https://github.com/jfree/jfreechart-fx/blob/83d824cc0b3b4f6481e74500ce9690f3157368ee/src/main/java/org/jfree/chart/fx/overlay/CrosshairOverlayFX.java#L90
For example, if the top chart has a weight of 2
and the bottom chart has a weight of 1
, then the computation above needs to be multiplied by 2/3
.