javascript - d3js (+crossfilter/dc) boxplot performance -


i'm trying use combination of d3, crossfilter, , dc generate interactive boxplots, using example: https://github.com/dc-js/dc.js/blob/master/web/examples/box-plot.html

my data looks more this:

id      date        met1 6368    10/24/2013  0.84 6369    10/24/2013  0.67 6374    10/24/2013  0.96 6375    10/24/2013  0.97 

with around half million data points, works fine else except boxplots. code works fine , boxplots fine, when change filter elsewhere takes forever boxplots update:

var met1dim = data.dimension(function(d) {return "metric 01";}); var met1values = met1dim.group().reduce(             function(p, v) {                 p.push(v.met1);                 return p;             },             function(p,v) {                 p.splice(p.indexof(v.met1), 1);                 return p;             },             function() {                 return [];             } 

performance drastically improved (but still not ideal) when pass integers data (just replacing v.met1 parseint(v.met1 * 100)), that's sort of half-assed , i'd display data in proper range, not coercing integer. significant slowdown occurs when i'm removing datasets, , think it's slice(indexof()) that's slowing down (when using floats). there can make operation faster? thinking maybe of associative array using id data key, i'm not sure how pass associative arrays reduce() function.

thanks.

using map lookup instead of indexof it's still unfortunate need jump through such hoops when want far can tell basic grouping met1 values showing @ top level because that's dc.js expects.

it nice if dc.js allowed specify accessor function allowed define how want met1 value pulled bound objects @ point @ it's needed. d3 uses pattern everywhere , it's convenient (and saves kind of performance intensive juggling).

barring sort of change dc.js, think idea map lookup best bet. can use closure scope of reduce functions store it. since records have unique ids can use single map without needing worry collisions:

var indexmap = {}; var met1values = met1dim.group().reduce(     function(p, v) {         indexmap[v.id] = p.length;  // length before push index of pushed element         p.push(v.met1);         return p;     },     function(p,v) {         p.splice(indexmap[v.id], 1);         return p;     },     function() {         return [];     } ); 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -