series.aggregate String|Function
(default: "max")
The aggregate function to apply for date series.
This function is used when a category (an year, month, etc.) contains two or more points. The function return value is displayed instead of the individual points.
The supported values are:
- "avg" - the average of all values for the date period.
- "count" - the number of values for the date period.
- "max" - the highest value for the date period.
- "min" - the lowest value for the date period.
- "sum" - the sum of all values for the date period. Defaults to 0 if no data points are defined.
- "sumOrNull" - the sum of all values for the date period. Defaults to
null
if no data points are defined. - "first" - the first value
- function(values, series, dataItems, category) - user-defined aggregate function. Returns single value or data item.
- object - (compound aggregate) Applicable to "candlestick", "boxPlot" and ohlc "series". Specifies the aggregate for each data item field.
Example - set the chart series aggregate
<div id="chart"></div>
<script>
$("#chart").kendoChart({
categoryAxis: {
categories: [
new Date("2012/01/01"),
new Date("2012/01/02"),
new Date("2012/01/02")
],
type: "date"
},
series: [{
data: [1, 2, 3],
aggregate: "avg"
}]
});
</script>
Example - set the chart series aggregate using a function
<div id="chart"></div>
<script>
$("#chart").kendoChart({
categoryAxis: {
categories: [
new Date("2012/01/01"),
new Date("2012/01/02"),
new Date("2012/01/02")
],
type: "date"
},
series: [{
data: [1, 2, 3],
aggregate: function(values, series, dataItems, category) {
// Two values with the same date(2 and 3), add them together and then divide them by the total number of values with the same category.
let average = values.reduce((a, b) => a + b) / values.length;
return average;
}
}]
});
</script>