fix(plugin-chart-echarts): boxplot throw error in the dashboard (#21661)

This commit is contained in:
Stephen Liu 2022-10-01 08:53:29 +08:00 committed by GitHub
parent 4c17f0e71e
commit 61bd696226
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -359,7 +359,7 @@ const show_empty_columns: SharedControlConfig<'CheckboxControl'> = {
const datetime_columns_lookup: SharedControlConfig<'HiddenControl'> = {
type: 'HiddenControl',
initialValue: (control: ControlState, state: ControlPanelState) =>
initialValue: (control: ControlState, state: ControlPanelState | null) =>
Object.fromEntries(
ensureIsArray<Record<string, any>>(state?.datasource?.columns)
.filter(option => option.is_dttm)

View File

@ -39,7 +39,7 @@ export const xAxisMixin = {
description: (state: ControlPanelState) =>
getAxisLabel(state?.form_data).description,
validators: [validateNonEmpty],
initialValue: (control: ControlState, state: ControlPanelState) => {
initialValue: (control: ControlState, state: ControlPanelState | null) => {
if (
isFeatureEnabled(FeatureFlag.GENERIC_CHART_AXES) &&
state?.form_data?.granularity_sqla &&

View File

@ -172,10 +172,14 @@ const config: ControlPanelConfig = {
label: t('Distribute across'),
multi: true,
description: t('Columns to calculate distribution across.'),
initialValue: (control: ControlState, state: ControlPanelState) => {
initialValue: (
control: ControlState,
state: ControlPanelState | null,
) => {
if (
(state && !control?.value) ||
(Array.isArray(control?.value) && control.value.length === 0)
state &&
(!control?.value ||
(Array.isArray(control?.value) && control.value.length === 0))
) {
return [getTemporalColumns(state.datasource).defaultTemporalColumn];
}