I’m using jqPlot to plot some points in my webApp, so I’m trying this:
var plot10 = $.jqplot ('heightChartDiv', [[3,7,9,1,5,3,8,2,5]]);
and it works fine, I this exact chart here
but when I take it out, to give it a value, like so:
$(document).ready(function(){
var serie1 = [[3,7,9,1,5,3,8,2,5]];
}
function doGraph(){
var plot10 = $.jqplot ('heightChartDiv', serie1);
}
It doesn’t work. am I declaring the variable wrong? please HELP!
~Myy
Your variable scoping is all off. The variable
serie1has local scope to the anonymous function defined in$(document).readyevent. Read up on javascript scope here and here.Perhaps something like this:
EDITS IN RESPONSE TO COMMENT
See this below example:
Here the variable a is considered global to the function someFunc. A variable declared in someFunc, though, does not persist outside of it.