最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - getContext error using chartjs - Stack Overflow

programmeradmin11浏览0评论

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'

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'
Share Improve this question edited Jun 16, 2015 at 15:06 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Sep 19, 2013 at 14:32 user1611830user1611830 4,86712 gold badges55 silver badges91 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 17

Ok, you have to use this instead

<canvas id="myChart" class="chart"></canvas>
发布评论

评论列表(0)

  1. 暂无评论