Chart.js: charts don't show up in IE 8
I get Object doesn't suport this property or method on this line:
var ctx = sellerGraph.get(0).getContext("2d");
I have included excanvas.
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 29 (7 by maintainers)
I know this is long closed, but I wanted to share some insight on this topic in case others needed it. I got chart.js working in IE8 and I had to do several different things to get it working.
Load the excanvas JS lib into your project
<head><script type="PATHTOJSFOLDER/js/excanvas.js"></script></head>(while you’re at it make sure that the Chart.js lib is properly loaded too)Implement Polyfills Implement 3 different polyfills for functions that are deprecated in legacy IE browsers:
Array.prototype.forEachforEach JS Page (Scroll down to Polyfill section)Object.keysObject.keys JS Page (Scroll down to Polyfill section)definePropertiesdefineProperties JS Page (Scroll down to Polyfill section)If you don’t want to manually insert the polyfills into your project & you’re lazy like me, polyfills for these functions can be found in the Modernizr JS Library & the lib can be loaded into your project.
Manually Create The Canvas Object Here’s the jquery that I used to render the canvas element inside of a div.
Insert Canvas Object Into Div And the chart was beautifully drawn in IE8 inside of this div (note how ID is referenced in code above, this places the chart’s
</div>`<canvas>element inside of the DIV): `<div id="event-chart-container">