I have a scatter chart, and I want to be able to move the points, to drag them
The problem is that it's not like a canvas, I apparently can't use eventgetX()
or getSceneX()
because there is the axis, which are not at the same position depending on the size of the scene, so the 0/0
is clearly not set depending of the chart, and if i changes the size of the scene, the distance : border/axis changes too
The code related to :
<ScatterChart fx:id="chart" onDragDetected="#chartDragDetected"
in the .fxml
and :
//The method associated with the chart
@FXML
void chartDragDetected(MouseEvent event) {
//Lots of try to find the coordinate but they change
//depending of the size of the scene
}
.
//in the initialize, populating the chart
double res=0;
for (double x = fct.getInf(); x<=fct.getSup(); x+=0.05 ){ //precision of graph
res = fct.f_de_x(x);
Data<Number,Number> dt = new Data<Number, Number>(x, res);
series.getData().add(dt);
}
chart.getData().add(series);
in the controller