Home forums Using CanvasJS Y data points do not graph Reply To: Y data points do not graph

#6372

hasanmnaqvi
Participant

Hi I used the method as mentioned and tried replicating the same in my html, but i get a weird error at the $ajax declaration "Uncaught ReferenceError: $ is not defined "

The code is here

<!DOCTYPE HTML>
<html>
<head>
<script type=”text/javascript”>
window.onload = function () {

$.ajax({
url : “http://api.wunderground.com/api/ac7e64a2f6e2d449/history_20130515/q/Ct/Higganum.json”,
dataType : “jsonp”,
success : function (parsed_json) {

var y = 0;
var data = [];
var dataSeries = {
type : “line”
};
var dataPoints = [];
var chart = new CanvasJS.Chart(“chartContainer”, {
zoomEnabled : true,
title : {
text : “Zoom And Observe AxisX Labels”,
},
axisX : {
labelAngle : 0,
},
axisY : {
includeZero : true,
},

legend : {
horizontalAlign : “right”,
verticalAlign : “center”,
},
data : data, // random generator below

});

var data_len = parsed_json.history.observations.length;
for (var i = 0; i < 3; i++) {
dataPoints.push({
x : i,
y : parsed_json.history.observations[i].tempi
});
// dataPoints.push({ x: i, y: 8}); // This works fine
console.log(parsed_json.history.observations[i].tempi);
alert(“hi”);
}
console.log(dataPoints);
dataSeries.dataPoints = dataPoints;
data.push(dataSeries);
chart.render();

}

});

}
</script>

<script type=”text/javascript” src=”D:\Hasan\Node.js\Canvas\canvasjs-1.4.1/canvasjs.min.js”></script>
</head>
<body>

<div id=”chartContainer4″ style=”height: 300px; width: 100%;”></div>

Hasan
</body>
</html>

  • This reply was modified 2 years, 5 months ago by  hasanmnaqvi. Reason: spelling mistake