dc.js - Simple line chart in DC and CrossFilter -


i have data this

var data =  [{date:'2013/01/01', claimno:1},              {date:'2013/01/01', claimno:2},              {date:'2013/01/02', claimno:3}] 

i want plot line chart in dc days on x-axis , total # of claims on y-axis.

i have code this

var ndx = crossfilter(data);  data.foreach(function (e) {     e.dd = dateformat.parse(e.dd);     e.month = d3.time.month(e.dd);  }); var datedim = ndx.dimension(function (d) {     return d.dd; }); var datesclaimsgroup = datedim.group(); var claimslinechart = dc.linechart("#claims-line-chart");   claimslinechart     .width(200)     .height(40)     .renderarea(true)     .margins({ top: 0, left: -1, right: 2, bottom: 1 })     .group(datesclaimsgroup)     .dimension(datedim)     .x(d3.time.scale().domain([data[0].dd, data[data.length - 1].dd]))     .title(function (d) {         return d.value;     }); 

the chart plotted values in y-axis date occurance counts , not claim counts. know supposed use function count claims not getting there.

for datesclaimsgroup need provide reduce function count claims. otherwise .group() default identity count reduce function observed.

var datesclaimsgroup = datedim.group().reducesum(...)  

or

var datesclaimsgroup = datedim.group().reduce(...)  

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -