]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Gracefully handle creating the chart with no config 2821/head
authorEvert Timberg <evert.timberg+github@gmail.com>
Tue, 21 Jun 2016 22:45:22 +0000 (18:45 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Tue, 21 Jun 2016 22:45:22 +0000 (18:45 -0400)
src/core/core.js

index 06b70735425b322a1fcef06ce19c18e7ad2252d7..9000dbd223cf8aa696576344fd177beded040e85 100755 (executable)
@@ -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() {