Monday, 9 September 2013

JavaFx Get the value of XYChart from MouseClicked Position

JavaFx Get the value of XYChart from MouseClicked Position

The method getXAxis().getValueForDisplay(mouseEvent.getX()); gives me
other values than expected.
I have a Chart extends XYChart which is added to a StackPane. In the Chart
i setted a event handler
setOnMouseClicked(new EventHandler() { @Override public void
handle(MouseEvent me) {
System.out.println("DataValue X at MousePosition " +
getXAxis().getValueForDisplay(me.getX()));
System.out.println("DataValue Y at MousePosition " +
getYAxis().getValueForDisplay(me.getY()));
}
});
Now for example, i click at Position x:15|y:10 but it returns me the
values x:17|y:6.
How to get the right Values ?

No comments:

Post a Comment