Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ended up using an approach that combined the results for each chart into one json response on the server side and then pulled them out on the client like thus:</p> <pre><code>var datasets = { "usa-line": { label: "USA", data: [[1988, 483994], [1989, 479060], [1990, 457648], [1991, 401949], [1992, 424705], [1993, 402375], [1994, 377867], [1995, 357382], [1996, 337946], [1997, 336185], [1998, 328611], [1999, 329421], [2000, 342172], [2001, 344932], [2002, 387303], [2003, 440813], [2004, 480451], [2005, 504638], [2006, 528692]] }, "usa-pie": { label: "USA", data: [[1, TOTAL GOES HERE]]] }, "russia-line": { label: "Russia", data: [[1988, 218000], [1989, 203000], [1990, 171000], [1992, 42500], [1993, 37600], [1994, 36600], [1995, 21700], [1996, 19200], [1997, 21300], [1998, 13600], [1999, 14000], [2000, 19100], [2001, 21300], [2002, 23600], [2003, 25100], [2004, 26100], [2005, 31100], [2006, 34700]] }, "russia-pie": { label: "Russia", data: [[1, TOTAL GOES HERE]]] } }; </code></pre> <p>Then on the callback for the ajax event, I parsed them out into separate datasets for each graph:</p> <pre><code>$.ajax({ type: "POST", dataType: 'json', url: "url goes here", data: "data goes here", success: function (datasets) { linedata = []; pieData = []; $.each (datasets, function (objName) { if(objName.indexOf('-line') != -1) linedata .push(datasets[objName]); else pieData.push(datasets[objName]); }); $.plot(plotarea, linedata , options /* options defined elsewhere */); $.plot(piearea, pieData, pieOptions /* pieOptions defined elsewhere */); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload