]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Document .getElementsAtXAxis(e) (#7718)
authorPavel <69010336+Ludar-Pavel@users.noreply.github.com>
Sat, 22 Aug 2020 16:25:28 +0000 (12:25 -0400)
committerGitHub <noreply@github.com>
Sat, 22 Aug 2020 16:25:28 +0000 (12:25 -0400)
Preventing pain for people with a specific use case.

docs/docs/developers/api.md

index 5e875146ea5c74f18045fc6676d87b6c20c8e2d9..d5dcb6e350338876bc6269a31e879674d5eba3c1 100644 (file)
@@ -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.