mirror of
https://github.com/apache/superset.git
synced 2026-04-25 11:04:48 +00:00
fix: Timeseries Y-axis format with contribution mode (#27106)
This commit is contained in:
committed by
GitHub
parent
13f1642c73
commit
af577d64b1
@@ -532,6 +532,7 @@ export default function transformProps(
|
||||
!!contributionMode,
|
||||
customFormatters,
|
||||
formatter,
|
||||
yAxisFormat,
|
||||
),
|
||||
},
|
||||
scale: truncateYAxis,
|
||||
@@ -554,6 +555,7 @@ export default function transformProps(
|
||||
!!contributionMode,
|
||||
customFormattersSecondary,
|
||||
formatterSecondary,
|
||||
yAxisFormatSecondary,
|
||||
),
|
||||
},
|
||||
scale: truncateYAxis,
|
||||
|
||||
@@ -95,6 +95,7 @@ import {
|
||||
} from '../constants';
|
||||
import { getDefaultTooltip } from '../utils/tooltip';
|
||||
import {
|
||||
getPercentFormatter,
|
||||
getTooltipTimeFormatter,
|
||||
getXAxisFormatter,
|
||||
getYAxisFormatter,
|
||||
@@ -253,7 +254,7 @@ export default function transformProps(
|
||||
const series: SeriesOption[] = [];
|
||||
|
||||
const forcePercentFormatter = Boolean(contributionMode || isAreaExpand);
|
||||
const percentFormatter = getNumberFormatter(',.0%');
|
||||
const percentFormatter = getPercentFormatter(yAxisFormat);
|
||||
const defaultFormatter = currencyFormat?.symbol
|
||||
? new CurrencyFormatter({ d3Format: yAxisFormat, currency: currencyFormat })
|
||||
: getNumberFormatter(yAxisFormat);
|
||||
@@ -486,6 +487,7 @@ export default function transformProps(
|
||||
forcePercentFormatter,
|
||||
customFormatters,
|
||||
defaultFormatter,
|
||||
yAxisFormat,
|
||||
),
|
||||
},
|
||||
scale: truncateYAxis,
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
getNumberFormatter,
|
||||
getTimeFormatter,
|
||||
isSavedMetric,
|
||||
NumberFormats,
|
||||
QueryFormMetric,
|
||||
smartDateDetailedFormatter,
|
||||
smartDateFormatter,
|
||||
@@ -30,14 +31,22 @@ import {
|
||||
ValueFormatter,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
export const getPercentFormatter = (format?: string) =>
|
||||
getNumberFormatter(
|
||||
!format || format === NumberFormats.SMART_NUMBER
|
||||
? NumberFormats.PERCENT
|
||||
: format,
|
||||
);
|
||||
|
||||
export const getYAxisFormatter = (
|
||||
metrics: QueryFormMetric[],
|
||||
forcePercentFormatter: boolean,
|
||||
customFormatters: Record<string, ValueFormatter>,
|
||||
defaultFormatter: ValueFormatter,
|
||||
format?: string,
|
||||
) => {
|
||||
if (forcePercentFormatter) {
|
||||
return getNumberFormatter(',.0%');
|
||||
return getPercentFormatter(format);
|
||||
}
|
||||
const metricsArray = ensureIsArray(metrics);
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user