Skip to content

Commit

Permalink
dimension panel fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Dec 3, 2020
1 parent e1258ed commit 1241d81
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions x-pack/plugins/lens/public/xy_visualization/xy_config_panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { TooltipWrapper } from './tooltip_wrapper';
import { getAxesConfiguration } from './axes_configuration';
import { PalettePicker } from '../shared_components';
import { getAccessorColorConfig, getColorAssignments } from './color_assignment';
import { getSortedAccessors } from './to_expression';

type UnwrapArray<T> = T extends Array<infer P> ? P : T;
type AxesSettingsConfigKeys = keyof AxesSettingsConfig;
Expand Down Expand Up @@ -579,6 +580,9 @@ const ColorPicker = ({
const currentColor = useMemo(() => {
if (overwriteColor || !frame.activeData) return overwriteColor;

const datasource = frame.datasourceLayers[layer.layerId];
const sortedAccessors: string[] = getSortedAccessors(datasource, layer);

const colorAssignments = getColorAssignments(
state.layers,
{ tables: frame.activeData },
Expand All @@ -587,11 +591,14 @@ const ColorPicker = ({
const mappedAccessors = getAccessorColorConfig(
colorAssignments,
frame,
layer,
[accessor],
{
...layer,
accessors: sortedAccessors.filter((sorted) => layer.accessors.includes(sorted)),
},
paletteService
);
return mappedAccessors[0].color;

return mappedAccessors.find((a) => a.columnId === accessor)?.color || null;
}, [overwriteColor, frame, paletteService, state.layers, accessor, formatFactory, layer]);

const [color, setColor] = useState(currentColor);
Expand Down

0 comments on commit 1241d81

Please sign in to comment.