The chart on page chart.html isn't displaying the bar graph as intended. The expected output can be found at https://www.chartjs.org/docs/latest/getting-started/
Content of chart.html
:
{% extends "base.html" %}
{% block js %}
<div>
<canvas id="myChart"></canvas>
</div>
<script src="../static/js/try.js"></script>
{% endblock %}
Inside try.js
:
import 'https://cdn.jsdelivr.net/npm/chart.js';
const ctx = document.getElementById('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],
borderWidth: 1
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});