in src/data.ts [394:433]
function createFacetsSelectionData(aggregatedData: AggregatedData, options: ConvertToFacetsVisualDataOptions) {
const { colors, settings } = options;
const colorPalette = colors ? COLOR_PALETTE.slice().concat(colors.map((color: IColorInfo) => color.value)) : COLOR_PALETTE.slice();
const toSelectionGroup = ((key: string) => {
const dataPoints = aggregatedData.dataPointsMap[key];
const facetGroupColor = colorPalette.shift();
const toSelectionSpec = (dp: DataPoint) => {
const {
highlight,
instanceValue,
instanceCount,
instanceCountFormatter,
instanceColor,
bucket,
sparklineData,
} = dp;
const selectionCountLabel = settings.display.selectionCount
? `${formatValue(instanceCountFormatter, highlight, '')} / ${formatValue(instanceCountFormatter, instanceCount, '')}`
: formatValue(instanceCountFormatter, instanceCount, '');
const selectionSpec = {
selected: { count: highlight, countLabel: selectionCountLabel },
value: instanceValue,
};
if (sparklineData) {
selectionSpec.selected['timeseries'] = createTimeSeries(aggregatedData.sparklineXDomain, sparklineData, true);
}
if (bucket) {
const segmentsBaseColor = instanceColor || hexToRgba(facetGroupColor, 100);
selectionSpec.selected['segments'] = createSegments(bucket, segmentsBaseColor, true);
}
return selectionSpec;
};
return {
key: key,
facets: dataPoints.filter((dp: DataPoint) => !!dp.highlight).map(toSelectionSpec)
};
});
return Object.keys(aggregatedData.dataPointsMap).map(toSelectionGroup);
}