Create chart in SharePoint webpart based on chart.js (SharePoint Online)

Iron Contributor

I found this very interesting blog about creating a chart in a Sharepoint page:


I tried to do this in my situation with my own list. Could not get it working. So I tried to create the exact same thing as in the example. But I make a missatke somewhre which I am not able to track.


Everything is running and executed but it ends up in an error:

<canvas id="lineChart" width="700" height="400" style="float:left;margin-right:20px;"></canvas><div id="chartDesc"></div>
TypeError: Unable to get property 'getContext' of undefined or null reference 

Looks like this piece of code is not converted to proper html or someting...

return '&lt;canvas id="lineChart" width="700" height="400" style="float:left;margin-right:20px;"&gt;&lt;/canvas&gt;&lt;div id="chartDesc"&gt;&lt;/div&gt;';




I'm a bit stuck now, can someone put me into the right direction?



Thanks, Mike

0 Replies