I'm trying to load a json file (static file) to chartjs. but it's not giving any result back.I'm using python to generate the json file. I'm new to jquery and javascript.
this is my code looks like.
<!doctype html>
<html>
<head>
<title>Bar Chart</title>
<script type="text/javascript" language="javascript" src="static/js/chart-min.js"></script>
<script type="text/javascript" language="javascript" src="static/js/util.js"></script>
<style>
canvas {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
</style>
</head>
<body>
<script>
<div id="container" style="width: 75%;">
<canvas id="canvas"></canvas>
</div>
$.getJSON( "var/graph.json", function( data ) {
var myChart = new Chart(ctx, {
type: 'bar',
data: data,
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
</script>
</body>
</html>
My static json file looks like this
{
"test_data": [
["aa", "11"],
["bb", "123"],
["cc", "81"],
["dd", "12"],
["ee", "22"]
]
}
What i'm missing here...i need to draw a line graph (x Axis - name (aa,bb,cc,dd) y Axis numbers (11,123,81,22) Appreciate your help on this.