I am trying to create a line chat by reading a .json file.
The following code I am trying :
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
<script type="text/javascript">
window.onload = function () {
var dataPoints = [];
var chart = new CanvasJS.Chart("chartContainer",{
title:{
text:"Rendering Chart with dataPoints from External JSON"
},
data: [{
type: "line",
dataPoints : dataPoints,
}]
});
$.getJSON("C:\Users\snehmani\Desktop\kumarchart.json", function(data) {
$.each(data, function(key, value){
dataPoints.push({x: value[0], y: parseInt(value[1])});
});
chart.render();
});
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
</body>
</html>
FORMAT OF .JSON FILE IS :
{
"Date & Time": "",
"Station": "",
"AP": "(mBar)",
"AT_Avg": "(°C)",
"AT_Max": "(°C)",
"AT_Min": "(°C)",
"BTY": "(Volt)",
"RadIn": "(W/m^2)",
"RadOut": "(W/m^2)",
"RH": "(%)",
"SD": "(mtr)",
"SDur": "(min)",
"SST": "(°C)",
"WS": "(m/s)"
}
PLEASE HELP ME OUT!