Skip to content

Commit

Permalink
feat(legacy-preset-chart-deckgl): Add ,.1f and ,.2f value formats to …
Browse files Browse the repository at this point in the history
…deckgl charts (#18945)

* Add ,.1f and ,.2f value formats to deckgl charts

* Remove duplicated code
  • Loading branch information
kgabryje committed Feb 28, 2022
1 parent 4775d39 commit c56dc8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +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)'],
[',.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 {
Expand Down

0 comments on commit c56dc8e

Please sign in to comment.