Skip to content

Commit

Permalink
Document .getElementsAtXAxis(e) (chartjs#7718)
Browse files Browse the repository at this point in the history
Preventing pain for people with a specific use case.
  • Loading branch information
pavel-lexyr authored Aug 22, 2020
1 parent ae214d9 commit 35d669e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/docs/developers/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ canvas.onclick = function(evt) {

This functionality may be useful for implementing DOM based tooltips, or triggering custom behaviour in your application.

## .getElementsAtXAxis(e)

Returns all elements at the data index the event point is located at. This is similar to `getElementsAtEvent(event)`, but the event point does not have to intersect one of the elements.

Calling `getElementsAtXAxis(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the point elements that are at that the same position of that event.

```javascript
canvas.onclick = function(evt) {
var activePoints = myLineChart.getElementsAtXAxis(evt);
// => activePoints is an array of points on the canvas that are at the same X axis as the click event.
};
```

## .getDatasetAtEvent(e)

Looks for the element under the event point, then returns all elements from that dataset. This is used internally for 'dataset' mode highlighting.
Expand Down

0 comments on commit 35d669e

Please sign in to comment.