* Horizontal Bar default tooltip mode was changed from `'index'` to `'nearest'` to match vertical bar charts
* `legend`, `title` and `tooltip` namespaces were moved from `Chart.defaults` to `Chart.defaults.plugins`.
* `elements.line.fill` default changed from `true` to `false`.
+* Line charts no longer override the default `interaction` mode. Default is changed from `'index'` to `'nearest'`.
#### Scales
#### Interactions
* To allow DRY configuration, a root options scope for common interaction options was added. `options.hover` and `options.plugins.tooltip` now both extend from `options.interaction`. Defaults are defined at `defaults.interaction` level, so by default hover and tooltip interactions share the same mode etc.
-* `interactions` are now limited to the chart area
+* `interactions` are now limited to the chart area + allowed overflow
* `{mode: 'label'}` was replaced with `{mode: 'index'}`
* `{mode: 'single'}` was replaced with `{mode: 'nearest', intersect: true}`
* `modes['X-axis']` was replaced with `{mode: 'index', intersect: false}`
* `options.onClick` is now limited to the chart area
* `options.onClick` and `options.onHover` now receive the `chart` instance as a 3rd argument
* `options.onHover` now receives a wrapped `event` as the first parameter. The previous first parameter value is accessible via `event.native`.
+* `options.hover.onHover` was removed, use `options.onHover`.
#### Ticks
it('should initialize config with default interaction options', function() {
var callback = function() {};
var defaults = Chart.defaults;
- var defaultMode = overrides.line.interaction.mode;
- defaults.hover.onHover = callback;
- overrides.line.interaction.mode = 'test';
+ defaults.onHover = callback;
+ overrides.line.interaction = {
+ mode: 'test'
+ };
var chart = acquireChart({
type: 'line'
var options = chart.options;
expect(options.font.size).toBe(defaults.font.size);
- expect(options.hover.onHover).toBe(callback);
+ expect(options.onHover).toBe(callback);
expect(options.hover.mode).toBe('test');
- defaults.hover.onHover = null;
- overrides.line.interaction.mode = defaultMode;
+ defaults.onHover = null;
+ delete overrides.line.interaction;
});
it('should initialize config with default hover options', function() {
var callback = function() {};
var defaults = Chart.defaults;
- defaults.hover.onHover = callback;
- overrides.line.hover.mode = 'test';
+ defaults.onHover = callback;
+ overrides.line.hover = {
+ mode: 'test'
+ };
var chart = acquireChart({
type: 'line'
var options = chart.options;
expect(options.font.size).toBe(defaults.font.size);
- expect(options.hover.onHover).toBe(callback);
+ expect(options.onHover).toBe(callback);
expect(options.hover.mode).toBe('test');
- defaults.hover.onHover = null;
- delete overrides.line.hover.mode;
+ defaults.onHover = null;
+ delete overrides.line.hover;
});
it('should override default options', function() {
var defaults = Chart.defaults;
var defaultSpanGaps = defaults.datasets.line.spanGaps;
- defaults.hover.onHover = callback;
- overrides.line.hover.mode = 'x-axis';
+ defaults.onHover = callback;
+ overrides.line.hover = {
+ mode: 'x-axis'
+ };
defaults.datasets.line.spanGaps = true;
var chart = acquireChart({
expect(options.hover.mode).toBe('dataset');
expect(options.plugins.title.position).toBe('bottom');
- defaults.hover.onHover = null;
- delete overrides.line.hover.mode;
+ defaults.onHover = null;
+ delete overrides.line.hover;
defaults.datasets.line.spanGaps = defaultSpanGaps;
});
axis: 'x' | 'y' | 'xy';
}
-export interface HoverInteractionOptions extends CoreInteractionOptions {
- /**
- * Called when any of the events fire. Passed the event, an array of active elements (bars, points, etc), and the chart.
- */
- onHover(event: ChartEvent, elements: ActiveElement[], chart: Chart): void;
-}
-
export interface CoreChartOptions<TType extends ChartType> extends ParsingOptions, AnimationOptions<TType> {
datasets: {
interaction: CoreInteractionOptions;
- hover: HoverInteractionOptions;
+ hover: CoreInteractionOptions;
/**
* The events option defines the browser events that the chart should listen to for tooltips and hovering.