This example sets the .transform property to a function that will place all but the top 5 query results into an "Other" pie slice.


  var chart = new Cedar({"type":"pie"});

  var dataset = {
    "url":"https://services.arcgis.com/uDTUpUPbk8X8mXwl/arcgis/rest/services/Public_Schools_in_Onondaga_County/FeatureServer/0",
    "query": {
      "orderByFields": "Number_of_SUM DESC",
      "groupByFieldsForStatistics": "Type",
      "outStatistics": [{
        "statisticType": "sum",
        "onStatisticField": "Number_of",
        "outStatisticFieldName": "Number_of_SUM"
      }]
    },
    "mappings":{
      "label": {"field":"Type","label":"Type"},
      "y": {"field":"Number_of_SUM","label":"Total Students"},
      "radius": 270
    }
  };
  chart.dataset = dataset;

  // only show the top 5 query results and
  // group the rest in an "other" slice
  chart.transform = function (queryResult, dataset) {
    var features = queryResult.features;
    var newFeatures = [];
    var outStatsField = dataset.query.outStatistics[0].outStatisticFieldName;
    var groupByField = dataset.query.groupByFieldsForStatistics;
    var numberOfSlices = 5;
    var sumOther = 0;
    // loop through the sorted query results
    for (var i = 0, len = features.length; i < len; i++) {
      var feature = features[i];
      if (i < numberOfSlices) {
        // this is in the top x features, let's include it
        newFeatures.push(features[i]);
      } else {
        // not in top x features, just incriment the sum
        sumOther = sumOther + feature.attributes[outStatsField];
      }
    }
    if (sumOther > 0) {
      // there were more than 5
      // add a record representing the rest
      var attr = {};
      attr[groupByField] = "Other";
      attr[outStatsField] = sumOther;
      newFeatures.push({
        attributes: attr
      });
    }
    // return the new features
    queryResult.features = newFeatures;
    return queryResult;
  };

  chart.tooltip = {
    "title": "{Type}",
    "content": "{Number_of_SUM} students"
  }
  chart.show({
    elementId: "#chart",
    width: 600,
    height: 600,
    autolabels: false
  });