Reputation: 129
I have the following custom reduce functions
function reduceAdd(p, v) {
p.vol_t += v.oqt;
p.prc_t += v.it;
++p.count;
// p.average = d3.round((p.total / p.count), 2);
return p;
}
function reduceRemove(p, v) {
p.vol_t -= v.oqt;
p.prc_t -= v.it;
--p.count;
// p.average = d3.round((p.total / p.count), 2);
return p;
}
function reduceInitial() {
return {
vol_t: 0.0,
prc_t: 0.0,
count: 0,
};
}
My data models is as follows:
[{cat:'a', oqt:23.0, it: 45.0},
{cat:'b', oqt:25.0, it: 5.0},
{cat:'b', oqt:22.0, it: 25.0},
{cat:'c', oqt:17.0, it: 35.0}]
I am trying to plot a bubble chart with dc.js with vol_t as X (keyAccessor), prc_t as Y axis (valueAccessor) and count as radiusAcessor. How do I find the max and min values across all groups. My groups are based on category 'cat' dimension.
Thanks!
Upvotes: 0
Views: 800
Reputation: 129
Solved it by using d3.extent and passing the category group and accessor function returning volume and price.
Upvotes: 1
Reputation: 6010
You can define an arbitrary ordering for a group based on its value: https://github.com/crossfilter/crossfilter/wiki/API-Reference#group_order
However, if you are using a dc.js bubble chart, I don't think it is necessary to define any particular ordering. You just need to define the proper accessors.
Upvotes: 3