mirror of
https://github.com/apache/superset.git
synced 2026-05-07 08:54:23 +00:00
feat: Dynamic currency (#36416)
This commit is contained in:
committed by
GitHub
parent
896947c787
commit
f4474b2e3e
@@ -36,6 +36,7 @@ import {
|
||||
isTimeseriesAnnotationLayer,
|
||||
QueryFormData,
|
||||
QueryFormMetric,
|
||||
resolveAutoCurrency,
|
||||
TimeseriesChartDataResponseResult,
|
||||
TimeseriesDataRecord,
|
||||
tooltipHtml,
|
||||
@@ -138,10 +139,11 @@ export default function transformProps(
|
||||
verboseMap = {},
|
||||
currencyFormats = {},
|
||||
columnFormats = {},
|
||||
currencyCodeColumn,
|
||||
} = datasource;
|
||||
const { label_map: labelMap } =
|
||||
const { label_map: labelMap, detected_currency: backendDetectedCurrency } =
|
||||
queriesData[0] as TimeseriesChartDataResponseResult;
|
||||
const { label_map: labelMapB } =
|
||||
const { label_map: labelMapB, detected_currency: backendDetectedCurrencyB } =
|
||||
queriesData[1] as TimeseriesChartDataResponseResult;
|
||||
const data1 = (queriesData[0].data || []) as TimeseriesDataRecord[];
|
||||
const data2 = (queriesData[1].data || []) as TimeseriesDataRecord[];
|
||||
@@ -279,20 +281,34 @@ export default function transformProps(
|
||||
xAxisType,
|
||||
});
|
||||
const series: SeriesOption[] = [];
|
||||
|
||||
const resolvedCurrency = resolveAutoCurrency(
|
||||
currencyFormat,
|
||||
backendDetectedCurrency,
|
||||
data1,
|
||||
currencyCodeColumn,
|
||||
);
|
||||
const resolvedCurrencySecondary = resolveAutoCurrency(
|
||||
currencyFormatSecondary,
|
||||
backendDetectedCurrencyB,
|
||||
data2,
|
||||
currencyCodeColumn,
|
||||
);
|
||||
|
||||
const formatter = contributionMode
|
||||
? getNumberFormatter(',.0%')
|
||||
: currencyFormat?.symbol
|
||||
: resolvedCurrency?.symbol
|
||||
? new CurrencyFormatter({
|
||||
d3Format: yAxisFormat,
|
||||
currency: currencyFormat,
|
||||
currency: resolvedCurrency,
|
||||
})
|
||||
: getNumberFormatter(yAxisFormat);
|
||||
const formatterSecondary = contributionMode
|
||||
? getNumberFormatter(',.0%')
|
||||
: currencyFormatSecondary?.symbol
|
||||
: resolvedCurrencySecondary?.symbol
|
||||
? new CurrencyFormatter({
|
||||
d3Format: yAxisFormatSecondary,
|
||||
currency: currencyFormatSecondary,
|
||||
currency: resolvedCurrencySecondary,
|
||||
})
|
||||
: getNumberFormatter(yAxisFormatSecondary);
|
||||
const customFormatters = buildCustomFormatters(
|
||||
@@ -300,14 +316,18 @@ export default function transformProps(
|
||||
currencyFormats,
|
||||
columnFormats,
|
||||
yAxisFormat,
|
||||
currencyFormat,
|
||||
resolvedCurrency,
|
||||
data1,
|
||||
currencyCodeColumn,
|
||||
);
|
||||
const customFormattersSecondary = buildCustomFormatters(
|
||||
[...ensureIsArray(metrics), ...ensureIsArray(metricsB)],
|
||||
currencyFormats,
|
||||
columnFormats,
|
||||
yAxisFormatSecondary,
|
||||
currencyFormatSecondary,
|
||||
resolvedCurrencySecondary,
|
||||
data2,
|
||||
currencyCodeColumn,
|
||||
);
|
||||
|
||||
const primarySeries = new Set<string>();
|
||||
|
||||
Reference in New Issue
Block a user