Skip to content

Commit

Permalink
expression fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Jul 1, 2020
1 parent 9cf9232 commit 9f42172
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
15 changes: 0 additions & 15 deletions x-pack/plugins/lens/public/xy_visualization/color_configuration.ts

This file was deleted.

4 changes: 2 additions & 2 deletions x-pack/plugins/lens/public/xy_visualization/to_expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ export const buildExpression = (
function: 'lens_xy_yConfig',
arguments: {
forAccessor: [yConfig.forAccessor],
axisMode: [yConfig.axisMode],
color: [yConfig.color],
axisMode: yConfig.axisMode ? [yConfig.axisMode] : [],
color: yConfig.color ? [yConfig.color] : [],
},
},
],
Expand Down
10 changes: 7 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 @@ -186,16 +186,20 @@ const ColorPicker = ({

const handleColor: EuiColorPickerProps['onChange'] = (newColor, output) => {
setColor(newColor, output);
if (output.isValid) {

if (output.isValid || newColor === '') {
const newYConfigs = [...(layer.yConfig || [])];
const existingIndex = newYConfigs.findIndex((yConfig) => yConfig.forAccessor === accessor);
if (existingIndex !== -1) {
newYConfigs[existingIndex].color = newColor;
if (newColor === '') {
delete newYConfigs[existingIndex].color;
} else {
newYConfigs[existingIndex].color = newColor;
}
} else {
newYConfigs.push({
forAccessor: accessor,
color: newColor,
axisMode: 'auto',
});
}
setState(updateLayer(state, { ...layer, yConfig: newYConfigs }, index));
Expand Down

0 comments on commit 9f42172

Please sign in to comment.