addSubField

adds a custom date field option for grouping data by dates

void addSubField(string name,function functor,string label);

Parameters

namestringthe name of the date field
functorfunctionthe function for grouping
labelstringthe label for a new option

Example

// groups data relatively to some specific date
var releaseDate = new Date(2017, 10, 10);
pivot.addSubField("when", function (val) { 
    return val > releaseDate ? "After" : "Before" 
}, "Release");
 
// groups data according to a custom date condition
pivot.addSubField("when", function (val) { 
    return val.getFullYear() + "-" + getMonth(val) 
}, "Year-Month");

See also
Back to top