This question already has an answer here:
I am making a line graph using a jQuery plug in and the script is as follows
<script>
var lineChartData = {
labels : ["1","2","3","4","5","6","7","8","9","10","11","12"],
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeolor : "#fff",
data : [5,6,19,34,59,93,128,158,206,266,329,398,418]
},
{
fillColor : "rgba(151,187,205,0.5)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#fff",
data : [0,0,0,3,15,46,68,109,169,228,319,364,386]
}
]
}
var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Line(lineChartData);
I want to insert a variable into the data part of the var, for example
data : [$q1,$q2,$q3, etc, etc]
I have no idea about javascript so I don't know where to begin. How would I do this?
I have the variables in a separate file and have included it this file.