Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getContext error using chartjs

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'
like image 796
user1611830 Avatar asked Sep 19 '13 14:09

user1611830


People also ask

Why is getContext not working?

The "getContext is not a function" error occurs when the getContext() method is called on a value that is not a canvas DOM element. To solve the error, make sure to only call the getContext method on canvas elements.

Can I use Chartjs with angular?

It is a command-line interface tool which is very useful for initialising and developing Angular applications.

How do I remove a dot in Chartjs?

You can set the pointRadius to zero.

Does Chartjs use WebGL?

js. Three. js is a cross-browser JavaScript library and application programming interface used to create and display animated 3D computer graphics in a web browser using WebGL.


1 Answers

Ok, you have to use this instead

<canvas id="myChart" class="chart"></canvas>
like image 153
epsilones Avatar answered Oct 01 '22 20:10

epsilones