I'm using Chartjs for the first time, and I'm having a problem with the import. When I was building my chart it didn't recognize "Chart" which led me to import it, but now it gives me the following error: "Cannot use import statement outside a module". If you can help me I would be extremely grateful.
My code:
<script src="node_modules/chart.js/dist/chart.min.js"></script>
<script>
import Chart from 'chart.js';
var ctx = document.getElementsByClassName('line-chart');
var chartGraph = new Chart(ctx, {
type: 'line',
date: {
labels: ["Jan", "Feb", "Mar"],
datasets: [{
label: 'Rate',
date: [5,10,5,14,20]
}]
}
});
</script>
<canvas class="line-chart"></canvas>`