]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix regression in x-axis interaction mode (#4762)
authorEvert Timberg <evert.timberg+github@gmail.com>
Sat, 16 Sep 2017 12:01:26 +0000 (08:01 -0400)
committerGitHub <noreply@github.com>
Sat, 16 Sep 2017 12:01:26 +0000 (08:01 -0400)
src/core/core.interaction.js
test/specs/global.deprecations.tests.js

index d984126ab5371a110d0c45041a100d54031d950a..be85a080f76760fd67ab81c8be38b2282fc55dd2 100644 (file)
@@ -215,7 +215,7 @@ module.exports = {
                 * @private
                 */
                'x-axis': function(chart, e) {
-                       return indexMode(chart, e, {intersect: true});
+                       return indexMode(chart, e, {intersect: false});
                },
 
                /**
index c5bef5b20b4725766a2df7682a80be0cbb94f98a..f1091464d1efaba1dda3e6c95792d824493188a1 100644 (file)
@@ -325,6 +325,45 @@ describe('Deprecations', function() {
                });
        });
 
+       describe('Version 2.4.0', function() {
+               describe('x-axis mode', function() {
+                       it ('behaves like index mode with intersect: false', function() {
+                               var data = {
+                                       datasets: [{
+                                               label: 'Dataset 1',
+                                               data: [10, 20, 30],
+                                               pointHoverBorderColor: 'rgb(255, 0, 0)',
+                                               pointHoverBackgroundColor: 'rgb(0, 255, 0)'
+                                       }, {
+                                               label: 'Dataset 2',
+                                               data: [40, 40, 40],
+                                               pointHoverBorderColor: 'rgb(0, 0, 255)',
+                                               pointHoverBackgroundColor: 'rgb(0, 255, 255)'
+                                       }],
+                                       labels: ['Point 1', 'Point 2', 'Point 3']
+                               };
+
+                               var chart = window.acquireChart({
+                                       type: 'line',
+                                       data: data
+                               });
+                               var meta0 = chart.getDatasetMeta(0);
+                               var meta1 = chart.getDatasetMeta(1);
+
+                               var evt = {
+                                       type: 'click',
+                                       chart: chart,
+                                       native: true, // needed otherwise things its a DOM event
+                                       x: 0,
+                                       y: 0
+                               };
+
+                               var elements = Chart.Interaction.modes['x-axis'](chart, evt);
+                               expect(elements).toEqual([meta0.data[0], meta1.data[0]]);
+                       });
+               });
+       });
+
        describe('Version 2.1.5', function() {
                // https://github.com/chartjs/Chart.js/pull/2752
                describe('Chart.pluginService', function() {