我正在vue js应用中使用amcharts 4。尝试使用可拖动的圆形项目符号构建XYChart。我在拖动或缩放选项(一个或另一个)之间进行切换,因此无论何时将鼠标悬停在其上,我都将可拖动状态设置为项目符号实例(idk,如果那是一种好方法)
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.
});
我正在考虑应该在子弹以外的其他实例上使用事件。我的主要目标是获取图表上拖动的项目符号的相对值,以便以此来更新数据。任何帮助或建议表示赞赏!
经过数小时的尝试找到最佳方法后,意识到光标对象是将坐标值附加到当前位置的最佳方法。
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/