mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-07 04:39:06 +02:00
Support jQuery' or native canvas element as chart context
This commit is contained in:
parent
1a3bb25f5c
commit
31643ee598
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user