mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
fix(charts): Hide Values greater than Max Y Axis Bound on Mixed Time Series with Bar series (#21015)
* Mixed TimeSeries: - When Bar chart is used as serie type, we need to hide values that are greater than the max Y Axis Bound. * Mixed Time Series: - Simplify logic for getOverMaxHiddenFormatter * Mixed Time Series: - Add tests for new getOverMaxHiddenFormatter util func
This commit is contained in:
committed by
GitHub
parent
d44202f03c
commit
bdcc0a9bcf
@@ -24,6 +24,7 @@ import {
|
||||
DTTM_ALIAS,
|
||||
ensureIsArray,
|
||||
GenericDataType,
|
||||
NumberFormats,
|
||||
NumberFormatter,
|
||||
TimeFormatter,
|
||||
} from '@superset-ui/core';
|
||||
@@ -326,3 +327,24 @@ export function getAxisType(dataType?: GenericDataType): AxisType {
|
||||
}
|
||||
return 'category';
|
||||
}
|
||||
|
||||
export function getOverMaxHiddenFormatter(
|
||||
config: {
|
||||
max?: number;
|
||||
formatter?: NumberFormatter;
|
||||
} = {},
|
||||
) {
|
||||
const { max, formatter } = config;
|
||||
// Only apply this logic if there's a MAX set in the controls
|
||||
const shouldHideIfOverMax = !!max || max === 0;
|
||||
|
||||
return new NumberFormatter({
|
||||
formatFunc: value =>
|
||||
`${
|
||||
shouldHideIfOverMax && value > max
|
||||
? ''
|
||||
: formatter?.format(value) || value
|
||||
}`,
|
||||
id: NumberFormats.OVER_MAX_HIDDEN,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user