I'm trying to use Chart.js
in my program. I have hosted my php and JavaScript files in a public hosting site. When I try to run the chart function, I'm getting the following error:
Uncaught TypeError: Cannot read property 'datasets' of undefined". Please find the code below.
<head>
<title>Operation Details</title>
<script src="../Chart.js"></script>
</head>
var barChartData = {
labels : [month1,month2,month3,month4,month5,month6,month7,month8,month9,month10,month11,month12],
datasets : [
{
label: "My First dataset", fillColor : "rgba(192,192,192,0.5)", strokeColor : "rgba(192,192,192,0.8)", highlightFill: "rgba(192,192,192,0.75)", highlightStroke: "rgba(192,192,192,1)",
data : [avg1[temp[i]],avg2[temp[i]]]
}
]
}
//...
window.onload = function(){
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx).Bar(barChartData, {
responsive: true
});
//...
}
Chart.js:
helpers.each(data.datasets,function(dataset,datasetIndex){
var datasetObject = {
//...
I'm completely new to JavaScript and to this forum. If something is wrong, please advice me on that.