mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
fix(plugin-chart-echarts): use scale for truncating x-axis (#26269)
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
|
||||
import { validateNumber } from '@superset-ui/core';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function parseAxisBound(
|
||||
bound?: string | number | null,
|
||||
): number | undefined {
|
||||
|
||||
@@ -41,7 +41,12 @@ import {
|
||||
StackControlsValue,
|
||||
TIMESERIES_CONSTANTS,
|
||||
} from '../constants';
|
||||
import { LegendOrientation, LegendType, StackType } from '../types';
|
||||
import {
|
||||
EchartsTimeseriesSeriesType,
|
||||
LegendOrientation,
|
||||
LegendType,
|
||||
StackType,
|
||||
} from '../types';
|
||||
import { defaultLegendPadding } from '../defaults';
|
||||
|
||||
function isDefined<T>(value: T | undefined | null): boolean {
|
||||
@@ -547,16 +552,35 @@ export function calculateLowerLogTick(minPositiveValue: number) {
|
||||
return Math.pow(10, logBase10);
|
||||
}
|
||||
|
||||
type BoundsType = {
|
||||
min?: number | 'dataMin';
|
||||
max?: number | 'dataMax';
|
||||
scale?: true;
|
||||
};
|
||||
|
||||
export function getMinAndMaxFromBounds(
|
||||
axisType: AxisType,
|
||||
truncateAxis: boolean,
|
||||
min?: number,
|
||||
max?: number,
|
||||
): { min: number | 'dataMin'; max: number | 'dataMax' } | {} {
|
||||
return truncateAxis && axisType === AxisType.value
|
||||
? {
|
||||
min: min === undefined ? 'dataMin' : min,
|
||||
max: max === undefined ? 'dataMax' : max,
|
||||
}
|
||||
: {};
|
||||
seriesType?: EchartsTimeseriesSeriesType,
|
||||
): BoundsType | {} {
|
||||
if (axisType === AxisType.value && truncateAxis) {
|
||||
const ret: BoundsType = {};
|
||||
if (seriesType === EchartsTimeseriesSeriesType.Bar) {
|
||||
ret.scale = true;
|
||||
}
|
||||
if (min !== undefined) {
|
||||
ret.min = min;
|
||||
} else if (seriesType !== EchartsTimeseriesSeriesType.Bar) {
|
||||
ret.min = 'dataMin';
|
||||
}
|
||||
if (max !== undefined) {
|
||||
ret.max = max;
|
||||
} else if (seriesType !== EchartsTimeseriesSeriesType.Bar) {
|
||||
ret.max = 'dataMax';
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user