Creating a custom reduce function with crossfilter and dc.js
I am trying to create a rowchart in dc.js which displays the count of a person divided by the hours they worked on a given date. My data is organized as follows:
Person Hours Date
Joe 3 1-2-16
Joe 3 1-2-16
Devon 5 1-2-16
Devon 5 1-2-16
Joe 4 1-3-16
Devon 1 1-3-16
Devon 1 1-3-16
How do I create a custom reduce function which can sum the count of the Person column (reduceCount) and divide it by the value of Hours for a specific date range? A given person has a set number of Hours on a given Date. So for example if I filter the data for all dates I want to return:
Joe 0.4286
Devon 0.6666
Which comes from total counts of Joe (3) divided by Hours Joe worked (7). Devon would be 4 divided by 6.
Filtering only the date 1-2-16, I would like to return:
Joe 0.6666
Devon 0.2
Which comes from total counts of Joe (2) divided by Hours Joe worked (3). Any suggestions?
链接地址: http://www.djcxy.com/p/32798.html上一篇: 绘制dc.js框图中单个列的唯一值