Reputation: 31
I'm completing my cs50 final project so am coding in the cs50 ide. I am trying to create a graph using chart.js so am using the test code they provide to try and get it to work on my website. However I am getting the error written in the title when I'm on my server. I have tried putting the JavaScript code in a separate file but that does not work either. Any ideas as to what i am doing wrong?
Here is my code
<!DOCTYPE html>
<html lang="en">
<head>
<script scr="https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.min.js"></script>
<title> Chart</title>
</head>
<body>
<canvas id="myChart" width="400" height="400"></canvas>
<script>
var ctx = document.getElementById('myChart').getContext('2d');
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],}]
}});
</script>
</body>
</html>
Upvotes: 0
Views: 1872
Reputation: 907
You have a typo in your chart JS script inclusion.
You have done scr
and not src
.
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.min.js"></script>
Upvotes: 1