So, I'm trying to implement CanvasJS into my project. I'm having a hard time trying to get the values from my structs to work in the tags. It works fine for the HTML code, but I'm not sure how to get it work for the javascript. Is it a different syntax?
<html>
<head>
<title>results</title>
<script src="http://canvasjs.com/assets/script/canvasjs.min.js"></script>
<script type="text/javascript">
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
title:{
text: "My First Chart in CanvasJS"
},
data: [
{
// Change type to "doughnut", "line", "splineArea", etc.
type: "column",
/*dataPoints: [
{ label: "Time", y: 10 },
{ label: "orange", y: 15 },
{ label: "banana", y: 25 },
{ label: "mango", y: 30 },
{ label: "grape", y: 28 }
]*/
dataPoints: [
{{range .Pair}}
{label: {{.Time}}, y: {{.Value}}}
{{end}}
]
}
]
});
chart.render();
}
</script>
</head>
<body>
<h1>{{.Id}}</h1>
<ol>
{{range .Pair}}
<ul>
<li>Time: {{.Time}}</li>
<li>Value: {{.Value}}</li>
</ul>
{{end}}
</ol>
<div id="chartContainer" style="height: 300px; width: 100%;"></div>
</body>