我的应用场景:我想通过点击数据点来获取点击点的数据和其他属性,然后通过PrimaryKey或其他属性来获取其他数据。用于显示在其他图表上。我目前遇到的问题是: LineSeries的onMouseClick事件返回的参数,找不到点击点的数据和其他属性;我尝试了两种方法,都找不到点击点的数据。
1
lineSeries.onMouseClick(function(serie, event) {
let point = serie.solveNearestFromScreen({
x: event.screenX,
y: event.screenY
});
console.log(point)
})2
lineSeries.onMouseClick(function(serie, event) {
console.log('serie', serie);
console.log('event', event);
})希望收到你的回音
发布于 2020-08-31 20:55:49
要获取鼠标单击时的数据点,可以在系列上注册onmouseclick事件,并调用solveNearestFromScreen方法来获取数据点。传递给solveNearestFromScreen的参数应该是鼠标光标位置转换为引擎位置的位置,例如,您可以参考以下代码:-
//attaching an on click event to the seires
series.onMouseClick( ( series, event ) => {
//convert client location to engine canvas location
const engineLocation = chart.engine.clientLocation2Engine( event.clientX, event.clientY )
//fetching the data point and other parameters. The location parameter gives the data point
console.log( series.solveNearestFromScreen( chart.engine.clientLocation2Engine( event.clientX, event.clientY ) ) )
} )https://stackoverflow.com/questions/63555748
复制相似问题