javascript - dc.js Number Display Widget -
javascript - dc.js Number Display Widget -
i'm new dc.js... , have little clue what's going on number display widget. tried looking @ illustration , copied sections of verbatim code hoping work (but knowing wouldn't). goal display average of line graph (sat scores) (that alter based on crossfilter). suggestions?...
var ndx = crossfilter(csv); var = ndx.groupall(); var bysat = ndx.dimension(function(d) { homecoming d.compositesat; }); var boxnd = dc.numberdisplay("#number-box"); var satavgnum = bysat.group().reduce( function (p, v) { ++p.n; p.tot += v.compositesat; homecoming p; }, function (p, v) { --p.n; p.tot -= v.compositesat; homecoming p; }, function () { homecoming {n:0,tot:0}; } ); var average = function(d) { homecoming d.n ? d.tot / d.n: 0; }; boxnd .formatnumber(d3.format(".3s")) .valueaccessor(average) .group(satavgnum);
"it doesn't work." result getting? 0? nan? blank?
if you're seeing result it's wrong, it's time pull out debugger , see what's wrong data. there couple of tips here:
https://github.com/dc-js/dc.js/wiki/faq#tell-whether-my-groups-are-functioning-correctly--whether-my-input-data-is-good
if you're not getting result, seek putting initial text #number-box
div, , seeing if gets overwritten.
indeed looks you've copied , pasted examples/number.html pretty faithfully, , hard what's going wrong without fiddle or @ to the lowest degree illustration of data.
javascript dc.js crossfilter
Comments
Post a Comment