mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Merge pull request #2680 from chartjs/fix/clipping
Remove clipping and add plugin hooks.
This commit is contained in:
commit
829c2be2bc
@ -399,7 +399,10 @@ Plugins should derive from Chart.PluginBase and implement the following interfac
|
||||
|
||||
// Easing is for animation
|
||||
beforeDraw: function(chartInstance, easing) { },
|
||||
afterDraw: function(chartInstance, easing) { }
|
||||
afterDraw: function(chartInstance, easing) { },
|
||||
// Before the datasets are drawn but after scales are drawn
|
||||
beforeDatasetDraw: function(chartInstance, easing) { },
|
||||
afterDatasetDraw: function(chartInstance, easing) { },
|
||||
|
||||
destroy: function(chartInstance) { }
|
||||
}
|
||||
|
||||
@ -288,12 +288,7 @@ module.exports = function(Chart) {
|
||||
this.scale.draw();
|
||||
}
|
||||
|
||||
// Clip out the chart area so that anything outside does not draw. This is necessary for zoom and pan to function
|
||||
var context = this.chart.ctx;
|
||||
context.save();
|
||||
context.beginPath();
|
||||
context.rect(this.chartArea.left, this.chartArea.top, this.chartArea.right - this.chartArea.left, this.chartArea.bottom - this.chartArea.top);
|
||||
context.clip();
|
||||
Chart.pluginService.notifyPlugins('beforeDatasetDraw', [this, easingDecimal]);
|
||||
|
||||
// Draw each dataset via its respective controller (reversed to support proper line stacking)
|
||||
helpers.each(this.data.datasets, function(dataset, datasetIndex) {
|
||||
@ -302,8 +297,7 @@ module.exports = function(Chart) {
|
||||
}
|
||||
}, this, true);
|
||||
|
||||
// Restore from the clipping operation
|
||||
context.restore();
|
||||
Chart.pluginService.notifyPlugins('afterDatasetDraw', [this, easingDecimal]);
|
||||
|
||||
// Finally draw the tooltip
|
||||
this.tooltip.transition(easingDecimal).draw();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user