From: Evert Timberg Date: Tue, 21 Jun 2016 22:45:22 +0000 (-0400) Subject: Gracefully handle creating the chart with no config X-Git-Tag: v2.2.0-rc.1~33^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2821%2Fhead;p=thirdparty%2FChart.js.git Gracefully handle creating the chart with no config --- diff --git a/src/core/core.js b/src/core/core.js index 06b707354..9000dbd22 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -6,7 +6,11 @@ module.exports = function() { var Chart = function(context, config) { var me = this; var helpers = Chart.helpers; - me.config = config; + me.config = config || { + data: { + datasets: [] + } + }; // Support a jQuery'd canvas element if (context.length && context[0].getContext) { @@ -45,10 +49,7 @@ 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); - - if (config) { - me.controller = new Chart.Controller(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() {