Tooltip: Render when animations are disabled (#8252)

This commit is contained in:
Jukka Kurkela 2020-12-30 15:33:30 +02:00 committed by GitHub
parent 6ffc380c6a
commit d00ffdcd76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 4 deletions

View File

@ -504,3 +504,4 @@ All helpers are now exposed in a flat hierarchy, e.g., `Chart.helpers.canvas.cli
* `afterEvent` and `beforeEvent` now receive a wrapped `event` as the `event` property of the second argument. The native event is available via `args.event.native`.
* Initial `resize` is no longer silent. Meaning that `resize` event can fire between `beforeInit` and `afterInit`
* New hooks: `install`, `start`, `stop`, and `uninstall`
* `afterEvent` should notify about changes that need a render by setting `args.changed` to true. Because the `args` are shared with all plugins, it should only be set to true and not false.

View File

@ -1035,7 +1035,7 @@ class Chart {
args.cancellable = false;
me.notifyPlugins('afterEvent', args);
if (changed) {
if (changed || args.changed) {
me.render();
}

View File

@ -1089,7 +1089,10 @@ export default {
if (chart.tooltip) {
// If the event is replayed from `update`, we should evaluate with the final positions.
const useFinalPosition = args.replay;
chart.tooltip.handleEvent(args.event, useFinalPosition);
if (chart.tooltip.handleEvent(args.event, useFinalPosition)) {
// notify chart about the change, so it will render
args.changed = true;
}
}
},

View File

@ -975,10 +975,11 @@ export interface Plugin<O = {}> extends ExtendedPlugin {
* @param {Chart} chart - The chart instance.
* @param {object} args - The call arguments.
* @param {ChartEvent} args.event - The event object.
* @param {boolean} replay - True if this event is replayed from `Chart.update`
* @param {boolean} args.replay - True if this event is replayed from `Chart.update`
* @param {boolean} [args.changed] - Set to true if the plugin needs a render. Should only be changed to true, because this args object is passed through all plugins.
* @param {object} options - The plugin options.
*/
afterEvent?(chart: Chart, args: { event: ChartEvent, replay: boolean }, options: O): void;
afterEvent?(chart: Chart, args: { event: ChartEvent, replay: boolean, changed?: boolean }, options: O): void;
/**
* @desc Called after the chart as been resized.
* @param {Chart} chart - The chart instance.