From a173f7434bb3e326889dbf2bcdefe62c729b75a2 Mon Sep 17 00:00:00 2001 From: Kamil Gabryjelski Date: Mon, 28 Feb 2022 12:26:49 +0100 Subject: [PATCH] Remove duplicated code --- .../src/utils/D3Formatting.ts | 2 ++ .../src/utilities/Shared_DeckGL.jsx | 7 ++++--- .../src/utilities/controls.jsx | 19 ------------------- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts b/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts index 2afac915269ba..02585cc58db90 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/src/utils/D3Formatting.ts @@ -34,6 +34,8 @@ export const D3_FORMAT_OPTIONS: [string, string][] = [ ['.2%', '.2% (12345.432 => 1234543.20%)'], ['.3%', '.3% (12345.432 => 1234543.200%)'], ['.4r', '.4r (12345.432 => 12350)'], + [',.1f', ',.1f (12345.432 => 12,345.4)'], + [',.2f', ',.2f (12345.432 => 12,345.43)'], [',.3f', ',.3f (12345.432 => 12,345.432)'], ['+,', '+, (12345.432 => +12,345.432)'], ['$,.2f', '$,.2f (12345.432 => $12,345.43)'], diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/Shared_DeckGL.jsx b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/Shared_DeckGL.jsx index d3e3751479a36..b801338f0c285 100644 --- a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/Shared_DeckGL.jsx +++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/Shared_DeckGL.jsx @@ -21,8 +21,8 @@ import React from 'react'; import { t, validateNonEmpty } from '@superset-ui/core'; -import { sharedControls } from '@superset-ui/chart-controls'; -import { D3_FORMAT_OPTIONS, columnChoices, PRIMARY_COLOR } from './controls'; +import { D3_FORMAT_OPTIONS, sharedControls } from '@superset-ui/chart-controls'; +import { columnChoices, PRIMARY_COLOR } from './controls'; const DEFAULT_VIEWPORT = { longitude: 6.85236157047845, @@ -161,9 +161,10 @@ export const legendFormat = { description: t('Choose the format for legend values'), type: 'SelectControl', clearable: false, - default: D3_FORMAT_OPTIONS[0], + default: D3_FORMAT_OPTIONS[0][0], choices: D3_FORMAT_OPTIONS, renderTrigger: true, + freeForm: true, }, }; diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/controls.jsx b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/controls.jsx index 4f9693c17ffe3..03092e7316af6 100644 --- a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/controls.jsx +++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/controls.jsx @@ -27,25 +27,6 @@ export function columnChoices(datasource) { return []; } -// input choices & options -export const D3_FORMAT_OPTIONS = [ - ['SMART_NUMBER', 'Adaptative formating'], - ['~g', 'Original value'], - [',d', ',d (12345.432 => 12,345)'], - ['.1s', '.1s (12345.432 => 10k)'], - ['.3s', '.3s (12345.432 => 12.3k)'], - [',.1%', ',.1% (12345.432 => 1,234,543.2%)'], - ['.3%', '.3% (12345.432 => 1234543.200%)'], - ['.4r', '.4r (12345.432 => 12350)'], - [',.1f', ',.1f (12345.432 => 12,345.4)'], - [',.2f', ',.2f (12345.432 => 12,345.43)'], - [',.3f', ',.3f (12345.432 => 12,345.432)'], - ['+,', '+, (12345.432 => +12,345.432)'], - ['$,.2f', '$,.2f (12345.432 => $12,345.43)'], - ['DURATION', 'Duration in ms (66000 => 1m 6s)'], - ['DURATION_SUB', 'Duration in ms (100.40008 => 100ms 400µs 80ns)'], -]; - export const PRIMARY_COLOR = { r: 0, g: 122, b: 135, a: 1 }; export default {