From: Tanner Linsley Date: Sat, 13 Jun 2015 08:41:15 +0000 (-0600) Subject: Support jQuery' or native canvas element as chart context X-Git-Tag: 2.0.0-alpha2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31643ee5987ec1444e0cf2b2547f945a9b4d184f;p=thirdparty%2FChart.js.git Support jQuery' or native canvas element as chart context --- diff --git a/src/core/core.js b/src/core/core.js index be5654ef7..6260c3a69 100755 --- a/src/core/core.js +++ b/src/core/core.js @@ -20,6 +20,17 @@ //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;