I started a project on our SharePoint. My plan was to create a dynamic chart with Chart.js in the script editor webpart. First I used fixed datasets to test the basics.
My problem is, that there is no result shown on the site. The site is blank at all. I tried the code at jsfiddle and it worked fine.
I also tried it with uploading Chart.js to our Sharepoint and refer to the uploaded file but nothing happens...
Here my code:
<canvas id="myChart" width="400" height="200"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.js" ></script>
<script>
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: ['rgba(255, 99, 132, 0.2)'],
borderColor: ['rgba(255,99,132,1)'],
borderWidth: 1
}]
},
options: {responsive:false,
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});
</script>