Skip to content

Commit

Permalink
fix the palette bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Oct 27, 2023
1 parent 3e651fc commit d06095e
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 75 deletions.
Expand Up @@ -28,6 +28,7 @@ export function CollapseSetting({
return (
<>
<EuiFormRow
id="lns-indexPattern-collapse-by"
label={
<EuiToolTip
delay="long"
Expand Down
134 changes: 66 additions & 68 deletions x-pack/plugins/lens/public/visualizations/metric/dimension_editor.tsx
Expand Up @@ -143,78 +143,77 @@ function SecondaryMetricEditor({ accessor, idPrefix, frame, layerId, setState, s
const defaultPrefix = columnName || '';

return (
<div data-test-subj="lnsMetricDimensionEditor_secondary_metric">
<EuiFormRow
display="columnCompressed"
fullWidth
label={i18n.translate('xpack.lens.metric.prefixText.label', {
defaultMessage: 'Prefix',
})}
>
<>
<EuiButtonGroup
isFullWidth
buttonSize="compressed"
legend={i18n.translate('xpack.lens.metric.prefix.label', {
defaultMessage: 'Prefix',
})}
data-test-subj="lnsMetric_prefix_buttons"
options={[
{
id: `${idPrefix}auto`,
label: i18n.translate('xpack.lens.metric.prefix.auto', {
defaultMessage: 'Auto',
}),
'data-test-subj': 'lnsMetric_prefix_auto',
value: undefined,
},
{
id: `${idPrefix}custom`,
label: i18n.translate('xpack.lens.metric.prefix.custom', {
defaultMessage: 'Custom',
}),
'data-test-subj': 'lnsMetric_prefix_custom',
value: defaultPrefix,
},
{
id: `${idPrefix}none`,
label: i18n.translate('xpack.lens.metric.prefix.none', {
defaultMessage: 'None',
}),
'data-test-subj': 'lnsMetric_prefix_none',
value: '',
},
]}
idSelected={`${idPrefix}${
state.secondaryPrefix === undefined
? 'auto'
: state.secondaryPrefix === ''
? 'none'
: 'custom'
}`}
onChange={(_id, secondaryPrefix) => {
<EuiFormRow
display="columnCompressed"
fullWidth
label={i18n.translate('xpack.lens.metric.prefixText.label', {
defaultMessage: 'Prefix',
})}
>
<>
<EuiButtonGroup
isFullWidth
buttonSize="compressed"
legend={i18n.translate('xpack.lens.metric.prefix.label', {
defaultMessage: 'Prefix',
})}
data-test-subj="lnsMetric_prefix_buttons"
options={[
{
id: `${idPrefix}auto`,
label: i18n.translate('xpack.lens.metric.prefix.auto', {
defaultMessage: 'Auto',
}),
'data-test-subj': 'lnsMetric_prefix_auto',
value: undefined,
},
{
id: `${idPrefix}custom`,
label: i18n.translate('xpack.lens.metric.prefix.custom', {
defaultMessage: 'Custom',
}),
'data-test-subj': 'lnsMetric_prefix_custom',
value: defaultPrefix,
},
{
id: `${idPrefix}none`,
label: i18n.translate('xpack.lens.metric.prefix.none', {
defaultMessage: 'None',
}),
'data-test-subj': 'lnsMetric_prefix_none',
value: '',
},
]}
idSelected={`${idPrefix}${
state.secondaryPrefix === undefined
? 'auto'
: state.secondaryPrefix === ''
? 'none'
: 'custom'
}`}
onChange={(_id, secondaryPrefix) => {
setState({
...state,
secondaryPrefix,
});
}}
/>
<EuiSpacer size="s" />
{state.secondaryPrefix && (
<DebouncedInput
data-test-subj="lnsMetric_prefix_custom_input"
compressed
value={state.secondaryPrefix}
onChange={(newPrefix) => {
setState({
...state,
secondaryPrefix,
secondaryPrefix: newPrefix,
});
}}
/>
<EuiSpacer size="s" />
{state.secondaryPrefix && (
<DebouncedInput
compressed
value={state.secondaryPrefix}
onChange={(newPrefix) => {
setState({
...state,
secondaryPrefix: newPrefix,
});
}}
/>
)}
</>
</EuiFormRow>
</div>
)}
</>
</EuiFormRow>
);
}

Expand Down Expand Up @@ -581,7 +580,6 @@ export function DimensionEditorAdditionalSection({
}`}
onChange={(id) => {
const supportingVisualizationType = id.split('--')[1] as SupportingVisType;

switch (supportingVisualizationType) {
case 'trendline':
setState({
Expand Down
Expand Up @@ -148,13 +148,14 @@ export const toExpression = (
progressDirection: state.progressDirection as LayoutDirection,
color: state.color || getDefaultColor(state, isMetricNumeric),
icon: state.icon,
palette: state.palette?.params
? [
paletteService
.get(CUSTOM_PALETTE)
.toExpression(computePaletteParams(state.palette.params as CustomPaletteParams)),
]
: [],
palette:
isMetricNumeric && state.palette?.params
? [
paletteService
.get(CUSTOM_PALETTE)
.toExpression(computePaletteParams(state.palette.params as CustomPaletteParams)),
]
: [],
maxCols: state.maxCols ?? DEFAULT_MAX_COLUMNS,
minTiles: maxPossibleTiles ?? undefined,
inspectorTableId: state.layerId,
Expand Down

0 comments on commit d06095e

Please sign in to comment.