From 3d443e01269a3ec2bc44aa0cc6ab20be98809f87 Mon Sep 17 00:00:00 2001 From: Michael Gerber Date: Thu, 24 Oct 2024 19:43:04 +0200 Subject: [PATCH] feat(number-format): Add duration formatter with colon notation (#30593) --- .../superset-ui-chart-controls/src/utils/D3Formatting.ts | 1 + superset-frontend/src/setup/setupFormatters.ts | 4 ++++ 2 files changed, 5 insertions(+) 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 5541c4a4b4574..d7fb542c6b6d8 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 @@ -57,6 +57,7 @@ export const D3_FORMAT_OPTIONS: [string, string][] = [ ...d3Formatted, ['DURATION', t('Duration in ms (66000 => 1m 6s)')], ['DURATION_SUB', t('Duration in ms (1.40008 => 1ms 400µs 80ns)')], + ['DURATION_COL', t('Duration in ms (10500 => 0:10.5)')], ['MEMORY_DECIMAL', t('Memory in bytes - decimal (1024B => 1.024kB)')], ['MEMORY_BINARY', t('Memory in bytes - binary (1024B => 1KiB)')], ]; diff --git a/superset-frontend/src/setup/setupFormatters.ts b/superset-frontend/src/setup/setupFormatters.ts index 384b1be9e30ae..b8b181fb7f1ae 100644 --- a/superset-frontend/src/setup/setupFormatters.ts +++ b/superset-frontend/src/setup/setupFormatters.ts @@ -78,6 +78,10 @@ export default function setupFormatters( 'DURATION_SUB', createDurationFormatter({ formatSubMilliseconds: true }), ) + .registerValue( + 'DURATION_COL', + createDurationFormatter({ colonNotation: true }), + ) .registerValue('MEMORY_DECIMAL', createMemoryFormatter({ binary: false })) .registerValue('MEMORY_BINARY', createMemoryFormatter({ binary: true }));