mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* 🐛 Use totalSeries only for data layers * ✅ Add test for custom breakdown palette Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
This commit is contained in:
parent
4415be95a3
commit
8e6cf28e19
2 changed files with 29 additions and 12 deletions
|
@ -108,7 +108,7 @@ export function getAccessorColorConfig(
|
|||
): AccessorConfig[] {
|
||||
const layerContainsSplits = Boolean(layer.splitAccessor);
|
||||
const currentPalette: PaletteOutput = layer.palette || { type: 'palette', name: 'default' };
|
||||
const totalSeriesCount = colorAssignments[currentPalette.name].totalSeriesCount;
|
||||
const totalSeriesCount = colorAssignments[currentPalette.name]?.totalSeriesCount;
|
||||
return layer.accessors.map((accessor) => {
|
||||
const currentYConfig = layer.yConfig?.find((yConfig) => yConfig.forAccessor === accessor);
|
||||
if (layerContainsSplits) {
|
||||
|
@ -132,17 +132,19 @@ export function getAccessorColorConfig(
|
|||
);
|
||||
const customColor =
|
||||
currentYConfig?.color ||
|
||||
paletteService.get(currentPalette.name).getCategoricalColor(
|
||||
[
|
||||
{
|
||||
name: columnToLabel[accessor] || accessor,
|
||||
rankAtDepth: rank,
|
||||
totalSeriesAtDepth: totalSeriesCount,
|
||||
},
|
||||
],
|
||||
{ maxDepth: 1, totalSeries: totalSeriesCount },
|
||||
currentPalette.params
|
||||
);
|
||||
(totalSeriesCount != null
|
||||
? paletteService.get(currentPalette.name).getCategoricalColor(
|
||||
[
|
||||
{
|
||||
name: columnToLabel[accessor] || accessor,
|
||||
rankAtDepth: rank,
|
||||
totalSeriesAtDepth: totalSeriesCount,
|
||||
},
|
||||
],
|
||||
{ maxDepth: 1, totalSeries: totalSeriesCount },
|
||||
currentPalette.params
|
||||
)
|
||||
: undefined);
|
||||
return {
|
||||
columnId: accessor as string,
|
||||
triggerIcon: customColor ? 'color' : 'disabled',
|
||||
|
|
|
@ -1039,6 +1039,21 @@ describe('xy_visualization', () => {
|
|||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('should be excluded and not crash when a custom palette is used for data layer', () => {
|
||||
const state = getStateWithBaseReferenceLine();
|
||||
// now add a breakdown on the data layer with a custom palette
|
||||
state.layers[0].palette = { type: 'palette', name: 'custom', params: {} };
|
||||
state.layers[0].splitAccessor = 'd';
|
||||
|
||||
const options = xyVisualization.getConfiguration({
|
||||
state,
|
||||
frame,
|
||||
layerId: 'referenceLine',
|
||||
}).groups;
|
||||
// it should not crash basically
|
||||
expect(options).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('color assignment', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue