custom ordering in custom reduce functions in dc.js crossfilter.js

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!


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.


通过使用d3.extent解决它,并传递类别组和访问器函数返回量和价格。

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

上一篇: 显示日期范围DC内的值的累计平均值

下一篇: 在dc.js crossfilter.js中的自定义reduce函数中进行自定义排序