in src/data.ts [335:392]
function aggregateDataPoints(dataPoints: DataPoint[], filter: DataPointsFilter = {}) {
const instanceMap = {};
const result = [];
dataPoints.forEach((dp: DataPoint) => {
const instanceLabel = dp.instanceLabel;
const handleDp = () => {
if (!checkRangeFilter(filter.range, dp.rangeValues) || !checkKeywordFilter(filter.contains, dp)) {
return;
}
if (!instanceMap[instanceLabel]) {
result.push(instanceMap[instanceLabel] = {
rows: dp.rows,
facetKey: dp.facetKey,
highlight: dp.highlight,
facetLabel: dp.facetLabel,
instanceValue: dp.instanceValue,
instanceLabel: dp.instanceLabel,
instanceCount: dp.instanceCount,
instanceCountFormatter: dp.instanceCountFormatter,
instanceColor: dp.instanceColor,
instanceIconClass: dp.instanceIconClass,
});
createBucket(instanceMap[instanceLabel], dp, 'bucket');
createBucket(instanceMap[instanceLabel], dp, 'sparklineData');
} else {
instanceMap[instanceLabel].highlight += dp.highlight;
instanceMap[instanceLabel].instanceCount += dp.instanceCount;
instanceMap[instanceLabel].rows.push(...dp.rows);
createBucket(instanceMap[instanceLabel], dp, 'bucket');
createBucket(instanceMap[instanceLabel], dp, 'sparklineData');
}
};
const handleSelectedDp = () => {
// keyword filter is not applied to the selected data points
!instanceMap[instanceLabel] && result.push(instanceMap[instanceLabel] = {
rows: [],
facetKey: dp.facetKey,
highlight: 0,
facetLabel: dp.facetLabel,
instanceValue: dp.instanceValue,
instanceLabel: dp.instanceLabel,
instanceCount: 0,
instanceCountFormatter: dp.instanceCountFormatter,
instanceColor: dp.instanceColor,
instanceIconClass: dp.instanceIconClass,
});
if (checkRangeFilter(filter.range, dp.rangeValues)) {
instanceMap[instanceLabel].highlight += dp.highlight;
instanceMap[instanceLabel].instanceCount += dp.instanceCount;
instanceMap[instanceLabel].rows.push(...dp.rows);
createBucket(instanceMap[instanceLabel], dp, 'bucket');
createBucket(instanceMap[instanceLabel], dp, 'sparklineData');
}
};
isInSelectedDataPoints(dp, filter.selectedDataPoints) ? handleSelectedDp() : handleDp();
});
return result;
}