checkMouseCoords(coords: Object);
coords. Mouse pointer coordinates.
The checkMouseCoords method checks if any point of chart data series corresponds to the specified coordinates.
The method returns a PP.Ui.ChartPoint type value.
Executing the example requires that the HTML page contains the Chart component named chart (see Example of Creating a Line Chart). Handle the chart data series events Click and OnContextMenu:
// Gets point by its position
function getPointByPosition(args) {
var coords = {
X: args.Event.x,
Y: args.Event.y
};
for (var i in chart.getSeries()) {
var serie = chart.getSeries()[i];
var point = serie.checkMouseCoords(coords, args.Event);
if (point) {
return point;
}
}
return null;
}
// Handle the Click event
function onChartClick(sender, args) {
var point = getPointByPosition(args);
if (point) {
var serie = point.getParent();
serie.Click.fire(serie, {
Point: point
});
}
};
// Handle the contextmenu event
function onContextMenu(sender, args) {
// Get data series point
var point = getPointByPosition(args);
if (point) {
var serie = point.getParent();
serie.OnContextMenu.fire(this, {
Point: point,
Serie: serie
});
}
};
// Add handler for the mouse click event
chart.addEvent(chart.getDomNode(), "click", onChartClick);
chart.addEvent(chart.getDomNode(), "contextmenu", onContextMenu);
Then select a random data series. After executing the example on clicking a point of chart data series its value is shown:
Selected point has the value 55 and is within the chart plot area
Selecting context menu for the point shows information on the data series that includes this point:
The data series is a forecast series with the index 0
Data series is selected
Data series is not highlighted
Data series is not hovered
See also: