Skip to content

Commit

Permalink
feat(explore): Denormalize form data in echarts, world map and nvd3 b…
Browse files Browse the repository at this point in the history
…ar and line charts (#20313)

* feat(explore): Apply denormalize form data function to echarts and world map

* Denormalize form data in mixed timeseries

* Add dist bar chart
  • Loading branch information
kgabryje authored Jun 9, 2022
1 parent d04357c commit 354a899
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ const config: ControlPanelConfig = {
Boolean(controls?.color_by.value === ColorBy.country),
},
},
denormalizeFormData: formData => ({
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ const config: ControlPanelConfig = {
timeSeriesSection[1],
sections.annotations,
],
denormalizeFormData: formData => ({
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ const config: ControlPanelConfig = {
],
controlOverrides: {
groupby: {
label: t('Dimensions'),
validators: [validateNonEmpty],
mapStateToProps: (state, controlState) => {
const groupbyProps =
Expand Down Expand Up @@ -134,6 +133,17 @@ const config: ControlPanelConfig = {
rerender: ['groupby'],
},
},
denormalizeFormData: formData => {
const columns =
formData.standardizedFormData.standardizedState.columns.filter(
col => !ensureIsArray(formData.groupby).includes(col),
);
return {
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
columns,
};
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ const config: ControlPanelConfig = {
default: 50000,
},
},
denormalizeFormData: formData => ({
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t } from '@superset-ui/core';
import { ensureIsArray, t } from '@superset-ui/core';
import {
D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS,
Expand Down Expand Up @@ -136,5 +136,16 @@ const config: ControlPanelConfig = {
),
},
},
denormalizeFormData: formData => {
const groupby =
formData.standardizedFormData.standardizedState.columns.filter(
col => !ensureIsArray(formData.columns).includes(col),
);
return {
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
groupby,
};
},
};
export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ const config: ControlPanelConfig = {
},
};
},
denormalizeFormData: formData => ({
...formData,
metric: formData.standardizedFormData.standardizedState.metrics[0],
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const config: ControlPanelConfig = {
name: 'groupby',
config: {
...sharedControls.groupby,
label: t('Dimensions'),
description: t('Columns to group by'),
},
},
Expand Down Expand Up @@ -309,6 +308,11 @@ const config: ControlPanelConfig = {
],
},
],
denormalizeFormData: formData => ({
...formData,
metric: formData.standardizedFormData.standardizedState.metrics[0],
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ const controlPanel: ControlPanelConfig = {
],
},
],
denormalizeFormData: formData => ({
...formData,
metric: formData.standardizedFormData.standardizedState.metrics[0],
}),
};

export default controlPanel;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
* under the License.
*/
import React from 'react';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import {
ensureIsArray,
FeatureFlag,
isFeatureEnabled,
t,
} from '@superset-ui/core';
import { cloneDeep } from 'lodash';
import {
ControlPanelConfig,
Expand Down Expand Up @@ -435,6 +440,21 @@ const config: ControlPanelConfig = {
],
},
],
denormalizeFormData: formData => {
const groupby =
formData.standardizedFormData.standardizedState.columns.filter(
col => !ensureIsArray(formData.groupby_b).includes(col),
);
const metrics =
formData.standardizedFormData.standardizedState.metrics.filter(
metric => !ensureIsArray(formData.metrics_b).includes(metric),
);
return {
...formData,
metrics,
groupby,
};
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ const config: ControlPanelConfig = {
],
},
],
denormalizeFormData: formData => ({
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ const config: ControlPanelConfig = {
default: rowLimit,
},
},
denormalizeFormData: formData => ({
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@ const config: ControlPanelConfig = {
default: rowLimit,
},
},
denormalizeFormData: formData => ({
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ const config: ControlPanelConfig = {
default: rowLimit,
},
},
denormalizeFormData: formData => ({
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ const config: ControlPanelConfig = {
denormalizeFormData: formData => ({
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ const config: ControlPanelConfig = {
default: rowLimit,
},
},
denormalizeFormData: formData => ({
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ const config: ControlPanelConfig = {
default: rowLimit,
},
},
denormalizeFormData: formData => ({
...formData,
metrics: formData.standardizedFormData.standardizedState.metrics,
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ const controlPanel: ControlPanelConfig = {
],
},
],
denormalizeFormData: formData => ({
...formData,
metric: formData.standardizedFormData.standardizedState.metrics[0],
}),
};

export default controlPanel;
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ const config: ControlPanelConfig = {
],
},
],
denormalizeFormData: formData => ({
...formData,
metric: formData.standardizedFormData.standardizedState.metrics[0],
groupby: formData.standardizedFormData.standardizedState.columns,
}),
};

export default config;

0 comments on commit 354a899

Please sign in to comment.