I'm trying to use ChartJS on NodeJS, but it doesn't work. I installed with npm install chart.js --save
and I created the simplest possible test as indicated below, but error Chart is not defined
displayed. I've already tried to copy the file "chart.js" to the same directory, I've already tried to point to the node_modules/chart.js/....
directory, but I can't make it work. Also I can't point the file https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js
, because system should work" stand alone "
<html>
<head>
<script src="chart.js"></script>
</head>
<body>
<canvas id="mycanvas" width="400" height="400"></canvas>
<script>
var chrt = document.getElementById("mycanvas").getContext("2d");
var data = {
labels: ["Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul"],
datasets: [{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.8)",
strokeColor: "rgba(220,220,220,0.8)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data: [65, 59, 80, 81, 56, 55, 40]
}]
};
var myFirstChart = new Chart(chrt).Bar(data);
</script>
</body>
</html>
What is wrong?