DC.js - capMixin



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]) − 獲取或設定上限的方向。如果設定了該方向,圖表則從資料元素的有序陣列中取前面的專案;否則,圖表將取後面的專案。

廣告