I have this series:
var series = chart.series.push(
am5xy.SmoothedXLineSeries.new(am5root, {
xAxis: xAxis,
yAxis: yAxis,
valueYField: "height",
valueXField: "number",
interactive: true,
interactiveChildren: true,
tooltip: am5.Tooltip.new(am5root, {
labelText:"{valueX}, {valueY}",
pointerOrientation:"horizontal"
})
})
);
and this event:
series.events.on("pointerover", function(ev) {
let xPosition = ev.point.x;
let yPosition = ev.point.y;
});
but the variables xPosition and yPosition contain the coordinates of the cursor, not the coordinates of the point on the graph. How to get coordinates of a points on the graph?
series.events.on("pointerover", function(ev) {
let xPosition = ev.point.x;
let yPosition = ev.point.y;
});
I got the result I needed this way:
series.events.on("globalpointermove", function(ev) {
if(typeof ev.target.getTooltip() === 'undefined' || typeof ev.target.getTooltip().dataItem==='undefined' || typeof ev.target.getTooltip().dataItem.dataContext === 'undefined') { return; }
else {
if(activeCharts){
let point = ev.target.getTooltip().dataItem.dataContext;
}
}
});