]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Support jQuery' or native canvas element as chart context
authorTanner Linsley <tannerlinsley@gmail.com>
Sat, 13 Jun 2015 08:41:15 +0000 (02:41 -0600)
committerTanner Linsley <tannerlinsley@gmail.com>
Sat, 13 Jun 2015 08:41:15 +0000 (02:41 -0600)
src/core/core.js

index be5654ef767d0d8e8e0c5bda084d644eafa31706..6260c3a69059cef927e0d6af873818e3ef37f77f 100755 (executable)
     //Occupy the global variable of Chart, and create a simple base class
     var Chart = function(context) {
         var chart = this;
+
+        // Support a jQuery'd canvas element
+        if (context.length && context[0].getContext) {
+            context = context[0];
+        }
+
+        // Support a canvas domnode
+        if (context.getContext) {
+            context = context.getContext("2d");
+        }
+
         this.canvas = context.canvas;
 
         this.ctx = context;