Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding hooks "beforeTooltipDraw" and "afterTooltipDraw" to plugins #4793

Merged
merged 9 commits into from
Oct 14, 2017
3 changes: 3 additions & 0 deletions src/core/core.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ module.exports = function(Chart) {

me.drawDatasets(easingValue);

// notify before drawing tooltips
plugins.notify(me, 'beforeTooltips', [easingValue]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't beforeTooltipDraw be more explicit and thus durable (e.g. if we decide to add beforeTooltipUpdate or whatever related to the tooltip)? Also, since there is only one managed tooltip, not sure it should be plural.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'd agree with this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I'll update it.


// Finally draw the tooltip
me.tooltip.draw();

Expand Down
10 changes: 10 additions & 0 deletions src/core/core.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ module.exports = function(Chart) {
* @param {Object} options - The plugin options.
* @returns {Boolean} `false` to cancel the chart drawing.
*/
/**
* @method IPlugin#beforeTooltips
* @desc Called before drawing `tooltips` at every animation frame specified by the given
* easing value. If any plugin returns `false`, the frame drawing is cancelled until
* another `render` is triggered.
* @param {Chart.Controller} chart - The chart instance.
* @param {Number} easingValue - The current animation value, between 0.0 and 1.0.
* @param {Object} options - The plugin options.
* @returns {Boolean} `false` to cancel the chart drawing.
*/
/**
* @method IPlugin#afterDraw
* @desc Called after the `chart` has been drawn for the specific easing value. Note
Expand Down