mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
feat(formatters): Add custom d3-time-format locale (#24263)
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { GenericDataType, smartDateFormatter, t } from '@superset-ui/core';
|
||||
import { GenericDataType, SMART_DATE_ID, t } from '@superset-ui/core';
|
||||
import {
|
||||
ControlPanelConfig,
|
||||
D3_FORMAT_DOCS,
|
||||
@@ -71,7 +71,7 @@ export default {
|
||||
renderTrigger: true,
|
||||
choices: D3_TIME_FORMAT_OPTIONS,
|
||||
description: D3_FORMAT_DOCS,
|
||||
default: smartDateFormatter.id,
|
||||
default: SMART_DATE_ID,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -20,7 +20,8 @@ import { PureComponent, MouseEvent } from 'react';
|
||||
import {
|
||||
t,
|
||||
getNumberFormatter,
|
||||
smartDateVerboseFormatter,
|
||||
getTimeFormatter,
|
||||
SMART_DATE_VERBOSE_ID,
|
||||
computeMaxFontSize,
|
||||
BRAND_COLOR,
|
||||
styled,
|
||||
@@ -45,7 +46,7 @@ class BigNumberVis extends PureComponent<BigNumberVizProps> {
|
||||
static defaultProps = {
|
||||
className: '',
|
||||
headerFormatter: defaultNumberFormatter,
|
||||
formatTime: smartDateVerboseFormatter,
|
||||
formatTime: getTimeFormatter(SMART_DATE_VERBOSE_ID),
|
||||
headerFontSize: PROPORTION.HEADER,
|
||||
kickerFontSize: PROPORTION.KICKER,
|
||||
mainColor: BRAND_COLOR,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { smartDateFormatter, t } from '@superset-ui/core';
|
||||
import { SMART_DATE_ID, t } from '@superset-ui/core';
|
||||
import {
|
||||
ControlPanelConfig,
|
||||
ControlSubSectionHeader,
|
||||
@@ -144,7 +144,7 @@ const config: ControlPanelConfig = {
|
||||
renderTrigger: true,
|
||||
choices: D3_TIME_FORMAT_OPTIONS,
|
||||
description: D3_FORMAT_DOCS,
|
||||
default: smartDateFormatter.id,
|
||||
default: SMART_DATE_ID,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -21,7 +21,7 @@ import moment from 'moment';
|
||||
import {
|
||||
getTimeFormatter,
|
||||
getTimeFormatterForGranularity,
|
||||
smartDateFormatter,
|
||||
SMART_DATE_ID,
|
||||
TimeGranularity,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
@@ -41,6 +41,6 @@ export const getDateFormatter = (
|
||||
granularity?: TimeGranularity,
|
||||
fallbackFormat?: string | null,
|
||||
) =>
|
||||
timeFormat === smartDateFormatter.id
|
||||
timeFormat === SMART_DATE_ID
|
||||
? getTimeFormatterForGranularity(granularity)
|
||||
: getTimeFormatter(timeFormat ?? fallbackFormat);
|
||||
|
||||
Reference in New Issue
Block a user