Partial Sums with DC.JS/Crossfilter

I have a data set set up with the following structure:

Q, FY, Name, Category, SubCategory, total, part1, part2, part3
q1, 2005, proj1, cat1, subcat1, 100, 25, 50, 25
q1, 2005, proj2, cat1, subcat1, 100, 25, 50, 25
q1, 2005, proj3, cat1, subcat1, 100, 25, 50, 25
q1, 2005, proj4, cat1, subcat1, 100, 25, 50, 25
q2, 2005, proj1, cat1, subcat1, 100, 25, 50, 25
q2, 2005, proj2, cat1, subcat1, 100, 25, 50, 25
q3, 2005, proj11, cat1, subcat1, 100, 25, 50, 25
q4, 2005, proj12, cat1, subcat1, 100, 25, 50, 25
q4, 2005, proj5, cat1, subcat1, 100, 25, 50, 25

I've been able to sum the totals according to the quarter within a fiscal year, and total the amounts according to the category, and was able to render this data to the graphs.

What I'm currently interested in, but having trouble with grasping, is how to loop through the part1, part2, part3 columns and obtain the sums of those columns then render them as a barchart with each column representing itself as it's own bar.. My goal is to be render a bar chart of the partial sums, then be able to adjust the totals according the filters on selected time frames or particular categories.

Any advice on how I could go about this?
Is it necessary to create a dimension for each column then sum the total according to that dimension, or is it just a matter of iterating through the columns with a loop?
ie looking to render a chart along the lines of this.. each column name is listed as an individual bar

在这里输入图像描述

Thanks in advance!


You can take a look at my response to similar question. In short, you need to format your data to look like this:

Q, FY, Name, Category, SubCategory, part
q1, 2005, proj1, cat1, subcat1, part1, 25
q1, 2005, proj2, cat1, subcat1, part2, 50
q1, 2005, proj2, cat1, subcat1, part3, 25

Here is an example: http://jsfiddle.net/jrideout/daaac/

链接地址: http://www.djcxy.com/p/32686.html

上一篇: dc.js / crossfilter性能问题12,000+行CSV数据

下一篇: 部分与DC.JS / Crossfilter相加