May be my question is silly but I need to plot a pie chart using dc.js that it has years as pieces but they all need to be same size no matter group data. i got data group from crossfilter.js as same value. However i need to know that there is any other way to get pie chart with same size pieces only using dimension?
1
votes
1 Answers
0
votes
I guess that's not really a pie chart anymore. However, I'd suggest doing this with a "fake group".
First go ahead and create a group for this, even though we won't use the values, we'll let crossfilter tally up the groups.
var group = dimension.group();
Then produce a "fake group" which, each time it's read, will set all the values to 1:
function all_equal_group(group) {
function make_equal(kvs) {
return kvs.map(function(kv) {
return {key: kv.key, value: 1};
});
}
return {
all: function() {
return make_equal(group.all());
},
top: function(N) {
return make_equal(group.top(N));
}
};
}
The top function is in case you're using capping. Maybe not needed here, but it won't hurt.
Apply it to your chart like this:
pieChart.group(all_equal_group(group));
dcis a venerable desk calculator from the 70's -dc.jsis the javascript dimensional charting library. - Gordon