Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Are you loading the CSV using d3.csv? If so, your current data transformation can be done without d3.nest(). Then d3.nest() can be used to rollup by quarter. Here's an example:</p> <pre><code>d3.csv('data.csv', function(row) { var key = row.x; var entries = d3.entries(row); // remove the first (the x column) entries.shift(); // map the rest of the columns entries = entries.map(function(entry) { return { value: entry.value, month: entry.key, quarter: (Math.floor((new Date(Date.parse(entry.key + "1, 2013")).getMonth()+1)/3+1)) }; }); // nest the array of months by quarter, rollup to return the mean var quarters = d3.nest() .key(function(d) { return +d.quarter; }) .rollup(function(d) { return d3.mean(d, function(d){ return +d.value; })}) .entries(entries); var months = d3.nest() .key(function(d) { return d.month; }) .rollup(function(d) { return d3.sum(d, function(d) { return +d.value; })}) .entries(entries); // return object for this row return { key: row.x, months: months, quarters: quarters }; }, function(data) { /* at this point data is an array of objects like: { key: 'Overall', months: [{key: January, values: 123} ....], quarters: [{key: 1, values: 4322}, ....] } */ console.log(data); }); </code></pre> <p><strong>UPDATE</strong> This will return a single array, each entry having a months and a quarters array. In your visualization code, you could just pull from the appropriate months or quarters property dynamically.</p> <p>Plunker here: <a href="http://plnkr.co/edit/sVt0T5LrTFJkMiVpkk8F?p=preview" rel="nofollow">http://plnkr.co/edit/sVt0T5LrTFJkMiVpkk8F?p=preview</a></p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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