Avoid errors when rendering serverside (#3909)

This commit is contained in:
Bohdan Khorolets 2017-03-21 02:37:34 +02:00 committed by Evert Timberg
parent 3e94b9431a
commit da1d1ca512
2 changed files with 9 additions and 1 deletions

View File

@ -56,4 +56,7 @@ plugins.push(require('./plugins/plugin.filler.js')(Chart));
Chart.plugins.register(plugins);
window.Chart = module.exports = Chart;
module.exports = Chart;
if (typeof window !== 'undefined') {
window.Chart = Chart;
}

View File

@ -669,6 +669,11 @@ module.exports = function(Chart) {
};
// Request animation polyfill - http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
helpers.requestAnimFrame = (function() {
if (typeof window === 'undefined') {
return function(callback) {
callback();
};
}
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||