capMixin 可以将低于某个值的数据元素列表分组为"其他".它适用于行图和饼图. capMixin的层次结构如下图所示.
capMixin提供了四种方法来查找"其他"部分,它们如下所示;
方法1:上限([count]) : 获取或设置将包含在上限中的元素数.
方法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]) : 获取或设置封顶的方向.如果设置,图表将从排序的数据元素数组中获取前面的项目;否则它将采取最后的项目.