mirror of
https://github.com/apache/superset.git
synced 2026-04-21 00:54:44 +00:00
fix(table): only show increase/decrease color options when time comparison enabled (#37362)
This commit is contained in:
@@ -683,16 +683,6 @@ const config: ControlPanelConfig = {
|
||||
type: 'ConditionalFormattingControl',
|
||||
renderTrigger: true,
|
||||
label: t('Custom conditional formatting'),
|
||||
extraColorChoices: [
|
||||
{
|
||||
value: ColorSchemeEnum.Green,
|
||||
label: t('Green for increase, red for decrease'),
|
||||
},
|
||||
{
|
||||
value: ColorSchemeEnum.Red,
|
||||
label: t('Red for increase, green for decrease'),
|
||||
},
|
||||
],
|
||||
description: t(
|
||||
'Apply conditional color formatting to numeric columns',
|
||||
),
|
||||
@@ -705,6 +695,22 @@ const config: ControlPanelConfig = {
|
||||
)
|
||||
? (explore?.datasource as Dataset)?.verbose_map
|
||||
: (explore?.datasource?.columns ?? {});
|
||||
const timeCompareValue = explore?.controls?.time_compare?.value;
|
||||
const hasTimeComparison = !isEmpty(timeCompareValue);
|
||||
|
||||
const extraColorChoices = hasTimeComparison
|
||||
? [
|
||||
{
|
||||
value: ColorSchemeEnum.Green,
|
||||
label: t('Green for increase, red for decrease'),
|
||||
},
|
||||
{
|
||||
value: ColorSchemeEnum.Red,
|
||||
label: t('Red for increase, green for decrease'),
|
||||
},
|
||||
]
|
||||
: [];
|
||||
|
||||
const chartStatus = chart?.chartStatus;
|
||||
const { colnames, coltypes } =
|
||||
chart?.queriesResponse?.[0] ?? {};
|
||||
@@ -724,12 +730,10 @@ const config: ControlPanelConfig = {
|
||||
colnames && coltypes[colnames?.indexOf(colname)],
|
||||
}))
|
||||
: [];
|
||||
const columnOptions = explore?.controls?.time_compare?.value
|
||||
const columnOptions = hasTimeComparison
|
||||
? processComparisonColumns(
|
||||
numericColumns || [],
|
||||
ensureIsArray(
|
||||
explore?.controls?.time_compare?.value,
|
||||
)[0]?.toString() || '',
|
||||
ensureIsArray(timeCompareValue)[0]?.toString() || '',
|
||||
)
|
||||
: numericColumns;
|
||||
|
||||
@@ -737,6 +741,7 @@ const config: ControlPanelConfig = {
|
||||
removeIrrelevantConditions: chartStatus === 'success',
|
||||
columnOptions,
|
||||
verboseMap,
|
||||
extraColorChoices,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user