Hello,
I am working on plotting to lines on a graph from a json file. Having an issue with plotting the second line.
json sample: [[0, 69.8, 53.0], [1, 69.8, 53.0], [2, 69.8, 53.0], [3, 69.8, 53.0]]
<!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 = [];
$.getJSON("data.json", function(data) {
$.each(data, function(key, value){
dataPoints.push({x: value[0], y: parseInt(value[1])});
dataPoints2.push({x: value[0], y: parseInt(value[2])});
});
var chart = new CanvasJS.Chart("chartContainer",{
title:{
text:"Plotting Temperature and Humidity"
},
data: [{
type: "line",
dataPoints : dataPoints,},
{
type: "line",
dataPoints : dataPoints2,
}]
});
chart.render();
});
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
</body>
</html>