I'm using amcharts 4 in vue js app. Trying to build an XYChart with draggable circle bullets. I'm toggling between drag or zooming options, its either one or other , so I'm setting up the draggable state to a bullet instance whenever its hover on and out (idk if thats a good approach)
this.bullet.events.on("over", e => {
e.target.interactions.draggable = this.darggableState;
});
this.bullet.events.on("drag", e => {
console.log(e.target.dataItem.valueY) // representation value of Y axis
console.log(e.target.relativeY) // infinity . As far as I understood this value
should represent relative Y axis value accordingly current bullet position on yAxis.
Meawhile I'm still able to get a pixel representation of position.
});
I'm considering that I might should use an event on some other instance than bullet. My main goal is to retrieve relative value of a dragged bullet on the chart so that I could update my data with it. Any help or advices appreciated !
After hours of trying to find the best approach , realized that cursor object is the best way to get reference to axis value accrodingly to current position.
this.chart.cursor.events.on("cursorpositionchanged", function(ev) {
var yAxis = ev.target.chart.yAxes.getIndex(0);
console.log("y: ", yAxis.positionToValue(yAxis.toAxisPosition(ev.target.yPosition)));
});
https://www.amcharts.com/docs/v4/tutorials/tracking-cursors-position-via-api/
or event on dragging event you can still access
const yAxis = this.chart.yAxes.getIndex(0);
const axisValue = yAxis.positionToValue(yAxis.toAxisPosition(this.chart.cursor.yPosition)