]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Limit onClick to chartArea (#6227)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Sun, 27 Oct 2019 20:29:07 +0000 (22:29 +0200)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sun, 27 Oct 2019 20:29:07 +0000 (16:29 -0400)
* Limit onClick to chartArea
* Utilize helpers.canvas._isPointInArea

src/core/core.controller.js

index 98cffef2673dbfb5d08feaba328d7a4356b03332..f56b049018317760c3f672659447122e94e753e7 100644 (file)
@@ -1080,7 +1080,7 @@ helpers.extend(Chart.prototype, /** @lends Chart */ {
                helpers.callback(options.onHover || options.hover.onHover, [e.native, me.active], me);
 
                if (e.type === 'mouseup' || e.type === 'click') {
-                       if (options.onClick) {
+                       if (options.onClick && helpers.canvas._isPointInArea(e, me.chartArea)) {
                                // Use e.native here for backwards compatibility
                                options.onClick.call(me, e.native, me.active);
                        }