1π
β
The syntax is different if you are using Chart.js v1 or v2.
You imported the v1 library using <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>
.
But you actually used the v2 syntax :
var myChart = new Chart(ctx, {
type: 'line',
data: {
// ...
}
});
To fix this, you can either :
-
Change the syntax to the v1βs :
var myChart= new Chart(ctx).Line({ labels: ['M', 'T', 'W', 'T', 'F', 'S', 'S'], datasets: [{ // ... }] });
-
(I suggest this option) Change your imported library to the latest one using :
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.min.js"></script>
π:1
include bundle.min.js
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.bundle.min.js"></script>
example with your code https://jsfiddle.net/sv4snt39/1/