English 中文(简体)
DC.js - capMixin
  • 时间:2024-12-22

DC.js - capMixin


Previous Page Next Page  

capMixin enables to group the pst of data element below a certain value as ‘Others’. It is apppcable in both row and pie charts. The hierarchy of the capMixin is as defined in the diagram below.

capMixin

capMixin provides four methods to find the Others section and they are as follows −

Method 1: cap( [count]) − Gets or sets the count of elements that will be included in the cap.

Method 2: othersGrouper( [grouperFunction]) − Gets or sets the function to do the ‘Others’ group. The default function provided is as follows.

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;
});

Method 3: othersLabel( [label]) − Gets or sets the label for ‘Others’ group.

Method 4: takeFront( [takeFront]) − Gets or sets the direction of capping. If set, the chart takes the front items from the sorted array of data elements; otherwise it will take the last items.

Advertisements