OK, this sounds like you're confused by the whole Javascript thing - I
think you need to step back and maybe draw a little diagram of how you
intend this to work.
The smallest possible change to the real data example is that you in
your success function simply put all the stuff (more or less) that the
real data example is doing in $(function () { ... }).
However, if what you want is the real data example but where the data
itself is stored server-side and only retrieved when needed, then you
should send a GET parameter to your getData.php script with the names
of the data you need, then modify it to return a dataset with exactly
that data in it and nothing more. I suggest you return an array like
you already have:
[
{label: "Data1", data:[[32,5.3],[64,9.5],[128,15.8],[256,26.0]]},
{label: "Data2", data:[[32,18.0],[64,32.0],[128,53.0],[256,67.]]}
]
The line "data.push(datasets[key]);" is for converting from an object
form { 'label1': data1, 'label2': data2 } to an array form [ data1,
data2 ] (push means append to array) since Flot needs the data in the
array form.
--
Ole Laursen
http://www.iola.dk/
Here's an example (warning, untested):
var myDataSets;
$.getJSON("get_data.php", function (data) {
myDataSets = data;
// this might be sometime later
myDataSets[0].lines = { show: true};
$.plot("#placeholder", myDataSets);
});
Think of it this way: you're designing a protocol where you control
both ends. It's a question of transfering the state from the server to
the client in the way that makes it as easy as possible for you to
manipulate it afterwards. JSON and the fact that Javascript has easy
dictionaries and arrays simplifies this a lot.