mirror of
https://github.com/apache/superset.git
synced 2026-05-10 02:15:50 +00:00
feat: Add currencies controls in control panels (#24718)
This commit is contained in:
committed by
Michael S. Molina
parent
dfd699f440
commit
10e781d0ff
@@ -142,6 +142,7 @@ export default function PivotTableChart(props: PivotTableProps) {
|
||||
rowTotals,
|
||||
rowSubTotals,
|
||||
valueFormat,
|
||||
currencyFormat,
|
||||
emitCrossFilters,
|
||||
setDataMask,
|
||||
selectedFilters,
|
||||
@@ -157,8 +158,14 @@ export default function PivotTableChart(props: PivotTableProps) {
|
||||
|
||||
const theme = useTheme();
|
||||
const defaultFormatter = useMemo(
|
||||
() => getNumberFormatter(valueFormat),
|
||||
[valueFormat],
|
||||
() =>
|
||||
currencyFormat?.symbol
|
||||
? new CurrencyFormatter({
|
||||
currency: currencyFormat,
|
||||
d3Format: valueFormat,
|
||||
})
|
||||
: getNumberFormatter(valueFormat),
|
||||
[valueFormat, currencyFormat],
|
||||
);
|
||||
const customFormatsArray = useMemo(
|
||||
() =>
|
||||
@@ -170,9 +177,9 @@ export default function PivotTableChart(props: PivotTableProps) {
|
||||
).map(metricName => [
|
||||
metricName,
|
||||
columnFormats[metricName] || valueFormat,
|
||||
currencyFormats[metricName],
|
||||
currencyFormats[metricName] || currencyFormat,
|
||||
]),
|
||||
[columnFormats, currencyFormats, valueFormat],
|
||||
[columnFormats, currencyFormat, currencyFormats, valueFormat],
|
||||
);
|
||||
const hasCustomMetricFormatters = customFormatsArray.length > 0;
|
||||
const metricFormatters = useMemo(
|
||||
|
||||
@@ -296,6 +296,7 @@ const config: ControlPanelConfig = {
|
||||
},
|
||||
},
|
||||
],
|
||||
['currency_format'],
|
||||
[
|
||||
{
|
||||
name: 'date_format',
|
||||
|
||||
@@ -104,6 +104,7 @@ export default function transformProps(chartProps: ChartProps<QueryFormData>) {
|
||||
metricsLayout,
|
||||
conditionalFormatting,
|
||||
timeGrainSqla,
|
||||
currencyFormat,
|
||||
} = formData;
|
||||
const { selectedFilters } = filterState;
|
||||
const granularity = extractTimegrain(rawFormData);
|
||||
@@ -161,6 +162,7 @@ export default function transformProps(chartProps: ChartProps<QueryFormData>) {
|
||||
rowTotals,
|
||||
rowSubTotals,
|
||||
valueFormat,
|
||||
currencyFormat,
|
||||
emitCrossFilters,
|
||||
setDataMask,
|
||||
selectedFilters,
|
||||
|
||||
@@ -67,6 +67,7 @@ interface PivotTableCustomizeProps {
|
||||
rowTotals: boolean;
|
||||
rowSubTotals: boolean;
|
||||
valueFormat: string;
|
||||
currencyFormat: Currency;
|
||||
setDataMask: SetDataMaskHook;
|
||||
emitCrossFilters?: boolean;
|
||||
selectedFilters?: SelectedFiltersType;
|
||||
|
||||
Reference in New Issue
Block a user