adds a custom date field option for grouping data by dates
name | string | the name of the date field |
functor | function | the function for grouping |
label | string | the label for a new option |
// 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");