populating variable for dynamic Jquery Graph
<p>I have the script below for a graphing system named flot, available to download. Basically what would be the best way to dynamically change the content of the array VAR data?? so I have a table of users and depending on the user I click on it populates that array with values, maybe when the page is first loaded i gather the data from php for all the users in the table (maybe 20 users max) then an onclick event which populates the var data variable and changes the graph. Just not sure how to go about doing it?? or even if I can.</p>

<p>Any help would be great thanks.</p>

<pre><code>  &lt;div id="placeholder" style="width:600px;height:300px"&gt;&lt;/div&gt;
  &lt;p&gt;&lt;input id="clearSelection" type="button" value="Clear selection" /&gt;

  &lt;input id="setSelection" type="button" value="Select year 1994" /&gt;&lt;/p&gt;
  &lt;p&gt;&lt;label&gt;&lt;input id="zoom" type="checkbox" /&gt;Zoom to selection.&lt;/label&gt;&lt;/p&gt;

&lt;script type="text/javascript"&gt;
$(function () {
var data = [
    {
        label: "United States",
        data: [[1990, 40.9], [1991, 18.7], [1992, 18.4], [1993, 19.3], [1994, 19.5], [1995, 19.3]]
    }
];

var options = {
    series: {
        lines: { show: true },
        points: { show: true }
    },
    legend: { noColumns: 2 },
    xaxis: { tickDecimals: 0 },
    yaxis: { min: 0 },
    selection: { mode: "x" }
};

var placeholder = $("#placeholder");

placeholder.bind("plotselected", function (event, ranges) {
    $("#selection").text(ranges.xaxis.from.toFixed(1) + " to " + ranges.xaxis.to.toFixed(1));

    var zoom = $("#zoom").attr("checked");
    if (zoom)
        plot = $.plot(placeholder, data,
                      $.extend(true, {}, options, {
                          xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
                      }));
});

placeholder.bind("plotunselected", function (event) {
    $("#selection").text("");
});

var plot = $.plot(placeholder, data, options);

$("#clearSelection").click(function () {
    plot.clearSelection();
});

$("#setSelection").click(function () {
    plot.setSelection({ xaxis: { from: 1994, to: 1995 } });
});
</code></pre>

<p>});
</p>

<p>
</p>
