Skip to content

Commit

Permalink
feat(explore): Apply denormalization to tier 2 charts form data (apac…
Browse files Browse the repository at this point in the history
…he#20524)

* feat(explore): Denormalize form data in Calendar Heatmap

* feat(explore): Denormalize form data in Bubble

* feat(explore): Denormalize form data in Chord

* Dimensions -> Dimension for single selection

* feat(explore): Denormalize form data in Country Map

* feat(explore): Denormalize form data in Heatmap

* feat(explore): Denormalize form data in Histogram

* feat(explore): Denormalize form data in Handlebars

* feat(explore): Denormalize form data in Percent Change

* Use new standardized form data interface
  • Loading branch information
kgabryje authored and akshatsri committed Jul 19, 2022
1 parent 0af966c commit 31ac7fa
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const dndColumnsControl: typeof dndGroupByControl = {

export const dndSeries: typeof dndGroupByControl = {
...dndGroupByControl,
label: t('Dimensions'),
label: t('Dimension'),
multi: false,
default: null,
description: t(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class StandardizedControlsManager {
return this.controls.metrics.shift();
}

shiftColumn() {
return this.controls.columns.shift();
}

popAllMetrics() {
return this.controls.metrics.splice(0, this.controls.metrics.length);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
D3_FORMAT_DOCS,
D3_TIME_FORMAT_OPTIONS,
formatSelectOptions,
getStandardizedControls,
sections,
} from '@superset-ui/chart-controls';

Expand Down Expand Up @@ -191,6 +192,10 @@ const config: ControlPanelConfig = {
label: t('Number Format'),
},
},
formDataOverrides: formData => ({
...formData,
metrics: getStandardizedControls().popAllMetrics(),
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t, validateNonEmpty } from '@superset-ui/core';
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';
import { ensureIsArray, t, validateNonEmpty } from '@superset-ui/core';
import {
ControlPanelConfig,
getStandardizedControls,
sections,
} from '@superset-ui/chart-controls';

const config: ControlPanelConfig = {
controlPanelSections: [
Expand Down Expand Up @@ -69,6 +73,16 @@ const config: ControlPanelConfig = {
description: t('Choose a target'),
},
},
formDataOverrides: formData => {
const groupby = getStandardizedControls()
.popAllColumns()
.filter(col => !ensureIsArray(formData.columns).includes(col));
return {
...formData,
groupby,
metric: getStandardizedControls().shiftMetric(),
};
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
D3_FORMAT_OPTIONS,
D3_FORMAT_DOCS,
sections,
getStandardizedControls,
} from '@superset-ui/chart-controls';
import { countryOptions } from './countries';

Expand Down Expand Up @@ -88,6 +89,11 @@ const config: ControlPanelConfig = {
renderTrigger: false,
},
},
formDataOverrides: formData => ({
...formData,
entity: getStandardizedControls().shiftColumn(),
metric: getStandardizedControls().shiftMetric(),
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
formatSelectOptionsForRange,
sections,
dndEntity,
getStandardizedControls,
} from '@superset-ui/chart-controls';

const sortAxisChoices = [
Expand Down Expand Up @@ -329,6 +330,10 @@ const config: ControlPanelConfig = {
label: t('Value Format'),
},
},
formDataOverrides: formData => ({
...formData,
metric: getStandardizedControls().shiftMetric(),
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
formatSelectOptions,
sections,
dndColumnsControl,
getStandardizedControls,
} from '@superset-ui/chart-controls';

const allColumns = {
Expand Down Expand Up @@ -160,5 +161,9 @@ const config: ControlPanelConfig = {
],
},
],
formDataOverrides: formData => ({
...formData,
groupby: getStandardizedControls().popAllColumns(),
}),
};
export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
formatSelectOptions,
D3_FORMAT_OPTIONS,
sections,
getStandardizedControls,
} from '@superset-ui/chart-controls';
import {
showLegend,
Expand Down Expand Up @@ -128,6 +129,11 @@ const config: ControlPanelConfig = {
renderTrigger: false,
},
},
formDataOverrides: formData => ({
...formData,
series: getStandardizedControls().shiftColumn(),
entity: getStandardizedControls().shiftColumn(),
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';
import {
ControlPanelConfig,
getStandardizedControls,
sections,
} from '@superset-ui/chart-controls';
import {
xAxisLabel,
yAxisLabel,
Expand Down Expand Up @@ -62,6 +66,11 @@ const config: ControlPanelConfig = {
timeSeriesSection[1],
sections.annotations,
],
formDataOverrides: formData => ({
...formData,
groupby: getStandardizedControls().popAllColumns(),
metrics: getStandardizedControls().popAllMetrics(),
}),
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import {
ControlPanelConfig,
emitFilterControl,
getStandardizedControls,
sections,
} from '@superset-ui/chart-controls';
import { addLocaleData, t } from '@superset-ui/core';
Expand Down Expand Up @@ -78,6 +79,11 @@ const config: ControlPanelConfig = {
],
},
],
formDataOverrides: formData => ({
...formData,
groupby: getStandardizedControls().popAllColumns(),
metrics: getStandardizedControls().popAllMetrics(),
}),
};

export default config;

0 comments on commit 31ac7fa

Please sign in to comment.