### Filter Callback
-Allows filtering of [tooltip items](#tooltip-item-interface). Must implement at minimum a function that can be passed to [Array.prototype.filter](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). This function can also accept a second parameter that is the data object passed to the chart.
+Allows filtering of [tooltip items](#tooltip-item-interface). Must implement at minimum a function that can be passed to [Array.prototype.filter](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). This function can also accept a fourth parameter that is the data object passed to the chart.
## Tooltip Callbacks
#### Tooltip
* `xLabel` and `yLabel` were removed. Please use `index` and `value`
+* The `filter` option will now be passed additional parameters when called and should have the method signature `function(tooltipItem, index, tooltipItems, data)`
## Developer migration
// If the user provided a filter function, use it to modify the tooltip items
if (options.filter) {
- tooltipItems = tooltipItems.filter((a) => options.filter(a, data));
+ tooltipItems = tooltipItems.filter((element, index, array) => options.filter(element, index, array, data));
}
// If the user provided a sorting function, use it to modify the tooltip items
options: {
tooltips: {
mode: 'index',
- filter: function(tooltipItem, data) {
+ filter: function(tooltipItem, index, tooltipItems, data) {
// For testing purposes remove the first dataset that has a tooltipHidden property
return !data.datasets[tooltipItem.datasetIndex].tooltipHidden;
}