dc.js - Making DCJS histogram based on the calculated average -


i have long format data following.

year company value 2001 aaaaaaa 200 2002 aaaaaaa 300 2003 aaaaaaa 400 2001 bbbbbbb 150 2002 bbbbbbb 250 2000 ccccccc 500 2001 ccccccc 600 2002 ccccccc 550 

is possible calculate average of income each company, make histogram calculated average on dc.js?

what first did make dimension company , calculate average, tried make average key.

problem faced there if tried make histogram out of that, have reducecount average dimension. of course average not exist on crossfilter object.

this jsfiddle script.
http://jsfiddle.net/adamist521/n1383zdk/3/
final image of graph included in script.

probably related 1 couldn't figure out how deal non-integer average.
dc.js histogram of crossfilter dimension counts

to calculate running average (crossfilter running calculations) need keep track of both sum , count. once have these, calculating average trivial. in fact, should not calculate averages in crossfilter @ all, track components. need use custom group track both count , sum on same group.

there example of such custom group in crossfilter documentation at: https://github.com/crossfilter/crossfilter/wiki/api-reference#group_order

in dc.js chart, define valueaccessor calculate average @ time of display:

chart.   ...   .valueaccessor(function(d){ return d.value.total/d.value.count; }) 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -