});
```
-## single (deprecated)
-Finds the first item that intersects the point and returns it. Behaves like `'nearest'` mode with `intersect = true`.
-
-## label (deprecated)
-See `'index'` mode.
-
## index
Finds item at the same index. If the `intersect` setting is true, the first intersecting item is used to determine the index in the data. If `intersect` false the nearest item, in the x direction, is used to determine the index.
});
```
-## x-axis (deprecated)
-Behaves like `'index'` mode with `intersect = false`.
-
## dataset
Finds items in the same dataset. If the `intersect` setting is true, the first intersecting item is used to determine the index in the data. If `intersect` false the nearest item is used to determine the index.
defaults._set('bar', {
hover: {
- mode: 'label'
+ mode: 'index'
},
scales: {
var resolve = helpers.options.resolve;
defaults._set('bubble', {
- hover: {
- mode: 'single'
- },
-
scales: {
xAxes: [{
type: 'linear', // bubble should probably use a linear scale by default
// Boolean - Whether we animate scaling the Doughnut from the centre
animateScale: false
},
- hover: {
- mode: 'single'
- },
legendCallback: function(chart) {
var list = document.createElement('ul');
var data = chart.data;
spanGaps: false,
hover: {
- mode: 'label'
+ mode: 'index'
},
scales: {
var defaults = require('../core/core.defaults');
defaults._set('scatter', {
- hover: {
- mode: 'single'
- },
-
scales: {
xAxes: [{
id: 'x-axis-1', // need an ID so datasets can reference the scale
* @return An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw
*/
getElementAtEvent: function(e) {
- return Interaction.modes.single(this, e);
+ return Interaction.modes.nearest(this, e, {intersect: true});
},
getElementsAtEvent: function(e) {
- return Interaction.modes.label(this, e, {intersect: true});
+ return Interaction.modes.index(this, e, {intersect: true});
},
getElementsAtXAxis: function(e) {
- return Interaction.modes['x-axis'](this, e, {intersect: true});
+ return Interaction.modes.index(this, e, {intersect: false});
},
getElementsAtEventForMode: function(e, mode, options) {
module.exports = {
// Helper function for different modes
modes: {
- single: function(chart, e) {
- var position = getRelativePosition(e, chart);
- var elements = [];
-
- parseVisibleItems(chart, function(element) {
- if (element.inRange(position.x, position.y)) {
- elements.push(element);
- return elements;
- }
- });
-
- return elements.slice(0, 1);
- },
-
- /**
- * @function Chart.Interaction.modes.label
- * @deprecated since version 2.4.0
- * @todo remove at version 3
- * @private
- */
- label: indexMode,
-
/**
* Returns items at the same index. If the options.intersect parameter is true, we only return items if we intersect something
* If the options.intersect mode is false, we find the nearest item and return the items at the same index as that item
return items;
},
- /**
- * @function Chart.Interaction.modes.x-axis
- * @deprecated since version 2.4.0. Use index mode and intersect == true
- * @todo remove at version 3
- * @private
- */
- 'x-axis': function(chart, e) {
- return indexMode(chart, e, {intersect: false});
- },
-
/**
* Point mode returns all elements that hit test based on the event position
* of the event
legend: false,
title: false,
hover: {
- mode: 'single'
+ mode: 'nearest',
+ intersect: true
},
scales: {
xAxes: [{
defaults.global.responsiveAnimationDuration = 0;
defaults.global.hover.onHover = null;
defaults.line.spanGaps = false;
- defaults.line.hover.mode = 'label';
+ defaults.line.hover.mode = 'index';
});
it('should override default options', function() {
defaults.global.responsiveAnimationDuration = 0;
defaults.global.hover.onHover = null;
- defaults.line.hover.mode = 'label';
+ defaults.line.hover.mode = 'index';
defaults.line.spanGaps = false;
});
},
options: {
tooltips: {
- mode: 'single'
+ mode: 'nearest',
+ intersect: true
}
}
});
},
options: {
tooltips: {
- mode: 'label',
+ mode: 'index',
callbacks: {
beforeTitle: function() {
return 'beforeTitle';
},
options: {
tooltips: {
- mode: 'label',
+ mode: 'index',
itemSort: function(a, b) {
return a.datasetIndex > b.datasetIndex ? -1 : 1;
}
},
options: {
tooltips: {
- mode: 'label',
+ mode: 'index',
reverse: true
}
}
},
options: {
tooltips: {
- mode: 'label'
+ mode: 'index'
}
}
});
},
options: {
tooltips: {
- mode: 'label',
+ mode: 'index',
filter: function(tooltipItem, data) {
// For testing purposes remove the first dataset that has a tooltipHidden property
return !data.datasets[tooltipItem.datasetIndex].tooltipHidden;
},
options: {
tooltips: {
- mode: 'single'
+ mode: 'nearest',
+ intersect: true
}
}
});
},
options: {
tooltips: {
- mode: 'single',
+ mode: 'nearest',
+ intersect: true,
callbacks: {
title: function() {
return 'registering callback...';
},
options: {
tooltips: {
- mode: 'label',
+ mode: 'index',
callbacks: {
beforeTitle: function() {
return 'beforeTitle\nnewline';