Basic JavaScript function variable access

It's been quite a while since I've played in JS, and function variable scope and access has me quite confused. I'm looking to populate a set of Google LineCharts with data and update every x seconds. I'd like to use a single array to store the data for each of the LineCharts, and then update the respective LineChart in another function using its index reference within the array. E.g. lineChart4.data = dataArray[3]. Note that the below sample code uses a single plot for simplicity.

Thanks for your input Is there not a 'function.variable' approach (e.g. var x = initialise.dataArray)? I'd prefer to use the callback method over global variables, but even then, it's a lot of passing around of variables when a reference would seem cleaner.

Your code won't work the way it's currently written. Try to just do everything in one big function and/or use global variables rather than trying to split it up into chunks. Make it work first. Then make it work better.

Try to avoid using "this.xxx" for variables. It's similar to a an instance variable (if you've done a bit of object-oriented stuff in the past) or a context binding (if you've done a bit of functional programming). Either way, it'll probably end of confusing you.

You can use "[]" as a shorthand notation for "new Array()". You don't need to predefine a size of an array in JS. Doing a push() will add a value to the array.

You can pass parameters into "callback" or "async" functions (stuff that will not run immediately) with SomeFunction.bind().

As a starting point, here's a few fixes that will get you a bit further. Once it starts making a bit of sense, try to figure out why this.chartPlot1 and chart.draw aren't working.