Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have a few variables that you can't access in a convenient way. How about holding them in an array so you can loop on them easily and search for the right dataset to take actions on? (from my comment above)</p> <p>You can make an array of the available data sets like this: <code>var datasets = new Array();</code>. Then, when defining a new dataset, do <code>datasets[] = { ...... }</code> instead of every <code>var Test1 = { ... };</code>.</p> <pre><code>var datasets = new Array(); datasets[0] = { "date": { label: "Date", data: [[1, 201], [2, 201], [3, 201], [4, 125]] }, "time": { label: "Time", data: [[1, 209], [2, 201], [3, 201], [4, 134]] }, "modules": { label: "Modules", data: [[1, 201], [2, 201], [3, 201], [4, 125]] }, "cases": { label: "Cases", data: [[1, 201], [2, 201], [3, 201], [4, 125]] }, "failed": { label: "Failed", data: [[1, 201], [2, 201], [3, 201], [4, 125]] }, "cover": { label: "Cover", data: [[1, 201], [2, 201], [3, 201], [4, 125]] } }; datasets[1] = { "date": { label: "Date", data: [[1, 201], [2, 201], [3, 201], [4, 125]] }, "time": { label: "Time", data: [[1, 201], [2, 201], [3, 201], [4, 125]] }, "modules": { label: "Modules", data: [[1, 201], [2, 201], [3, 201], [4, 125]] }, "cases": { label: "Cases", data: [[1, 101], [2, 201], [3, 201], [4, 45]] }, "failed": { label: "Failed", data: [[1, 301], [2, 454], [3, 43], [4, 125]] }, "cover": { label: "Cover", data: [[1, 201], [2, 201], [3, 201], [4, 125]] } }; </code></pre> <p>Then, you could access the datasets like this:</p> <pre><code>alert(datasets[1]); // datasets[0] holds the first test data, datasets[1] the second, and so on... $.plot($("#placeholder"), datasets[0]); </code></pre> <p>Your plotSingleCoverage can then be:</p> <pre><code>function plotSingleCoverage(dateset){ $.plot($("#placeholder"), dataset); } </code></pre> <p>And you can use it like this:</p> <pre><code>plotSingleCoverage(datasets[0]); </code></pre>
 

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