PCObject.isCoordsInside

Syntax

isCoordsInside(coords: Object);

Parameters

coords. Object that contains mouse coordinates. This object must include the following fields: X - X coordinate of cursor position; Y - Y coordinate of cursor position.

Description

The isCoordsInside method checks if the mouse cursor is over chart item.

Comments

The method returns true if the mouse cursor is over the item, and false if otherwise.

Example

Executing the example requires the ParallelCoordinates component named coord (see Example of Creating the ParallelCoordinates Component). Check if the first line of the chart is shown:

// Check if the first line in the chart is visible
if (coord.getLines()[0].getIsVisible()) {
    console.log("The first line is shown");
} else {
    console.log("The first line is not shown");
}

The result of checking is displayed in the console:

The first line is shown

 

Set event handler that handles clicking on the chart. Check if the mouse pointer hits the first line of the chart:

// Set event handler for mouse click on the chart
coord.Click.add(function(sender, args) {
    var offset = PP.calculateOffset(coord.getChartArea().getPaper());
    var clickCoords = { 
        X: args.Event.x-offset.X,
        Y: args.Event.y-offset.Y
    };
    // Check if the mouse pointer hits the first line
    if(coord.getLines()[0].isCoordsInside(clickCoords)) {
        console.log("The mouse is clicked in the first line");
    } else {
        console.log("The mouse is clicked not in the first line");
    }
});

After clicking the first chart line, corresponding message is displayed in the console:

The mouse is clicked in the first line

See also:

PCObject