6

I am following this tutorial [chart.js][1] and I get this error and this line

var ctx = $("#myChart").get(0).getContext("2d");

where $("#myChart") stands for <figure id="myChart" class="chart"></figure>

throws this error

Uncaught TypeError: Object #<HTMLElement> has no method 'getContext'
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user1611830
  • 4,749
  • 10
  • 52
  • 89

1 Answers1

17

Ok, you have to use this instead

<canvas id="myChart" class="chart"></canvas>
epsilones
  • 11,279
  • 21
  • 61
  • 85