crossfilter - dc.js pie chart sum example -
i have records :
{ {"pass": "10", "fail": "20", "untested": "40"} {"pass": "20", "fail": "40", "untested": "50"} {"pass": "30", "fail": "50", "untested": "60"} ... }
obviously, total = pass + fail + untested. want sum each of these values , show pie chart using dc.js shows total pass, total fail, total untested. couldnt find example.
in example below, each record converted binary loss/gain value. pie chart shows aggregated loss/gain. need aggregate @ collection level, not individual record level. how can ?
any appreciated.
ref:
take @ example in jsfiddle
the trick modify input data, can create dimension records on result. data should this:
[{"result":"pass","value":"10","_id":0}, {"result":"fail","value":"20","_id":0}, {"result":"untested","value":"40","_id":0}, {"result":"pass","value":"20","_id":1}, {"result":"fail","value":"40","_id":1}, {"result":"untested","value":"50","_id":1}, {"result":"pass","value":"30","_id":2}, {"result":"fail","value":"50","_id":2}, {"result":"untested","value":"60","_id":2}]
i did using new js library created called melt, simple duplicate same logic yourself. here example in recent user list discussion.
Comments
Post a Comment