DC.js - capMixin

capMixin 可以将某个值以下的数据元素列表分组为"其他"。它适用于行图和饼图。capMixin 的层次结构如下图所示。

capMixin

capMixin 提供了四种方法来查找其他部分,如下所示 −

方法 1:cap( [count]) − 获取或设置将包含在 cap 中的元素数量。

方法 2:othersGrouper( [grouperFunction]) − 获取或设置执行"其他"分组的函数。提供的默认函数如下。

chart.othersGrouper(function (topItems, restItems) {
   var restItemsSum = d3.sum(restItems, _chart.valueAccessor()),
   restKeys = restItems.map(_chart.keyAccessor());
   
   if (restItemsSum > 0) {
      return topItems.concat([{
         others: restKeys,
         key: _chart.othersLabel(),
         value: restItemsSum
      }]);
   }
   return topItems;
});

方法 3:othersLabel( [label]) − 获取或设置"其他"组的标签。

方法 4:takeFront( [takeFront]) − 获取或设置封顶方向。如果设置,图表将从已排序的数据元素数组中获取前面的项目;否则将获取最后的项目。