DC.js capMixin基础教程文档

收录于 2023-04-20 00:10:05 · بالعربية · English · Español · हिंदीName · 日本語 · Русский язык · 中文繁體

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