Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions samples/bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
}
},
responsive: true,
addResizeListener: false,
legend: {
position: 'top',
},
Expand Down
16 changes: 9 additions & 7 deletions src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ module.exports = function() {
// High pixel density displays - multiply the size of the canvas height/width by the device pixel ratio, then scale.
helpers.retinaScale(me);
me.controller = new Chart.Controller(me);

// Always bind this so that if the responsive state changes we still work
helpers.addResizeListener(context.canvas.parentNode, function() {
if (me.controller && me.controller.config.options.responsive) {
me.controller.resize();
}
});
if(me.config && me.config.options && me.config.options.addResizeListener === true) {
// Bind this if option addResizeListener is true (default true) so that if the responsive state changes we still work
helpers.addResizeListener(context.canvas.parentNode, function() {
if (me.controller && me.controller.config.options.responsive) {
me.controller.resize();
}
});
}

return me.controller ? me.controller : me;

Expand All @@ -66,6 +67,7 @@ module.exports = function() {
Chart.defaults = {
global: {
responsive: true,
addResizeListener: true,
responsiveAnimationDuration: 0,
maintainAspectRatio: true,
events: ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove'],
Expand Down