Skip to content

Commit

Permalink
Fix regression in x-axis interaction mode
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Sep 14, 2017
1 parent 4396a53 commit d7134e6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/core.interaction.js
Expand Up @@ -215,7 +215,7 @@ module.exports = {
* @private
*/
'x-axis': function(chart, e) {
return indexMode(chart, e, {intersect: true});
return indexMode(chart, e, {intersect: false});
},

/**
Expand Down
41 changes: 41 additions & 0 deletions test/specs/core.interaction.tests.js
Expand Up @@ -192,6 +192,47 @@ describe('Core.Interaction', function() {
});
});

describe('x-axis mode', 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']
};

beforeEach(function() {
this.chart = window.acquireChart({
type: 'line',
data: data
});
});

it ('behaves like index mode with intersect: false', function() {
var chart = this.chart;
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('dataset mode', function() {
describe('intersect: true', function() {
beforeEach(function() {
Expand Down

0 comments on commit d7134e6

Please sign in to comment.