mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(plugin-chart-echarts): calculate Gauge Chart intervals correctly when min value is set (#27285)
This commit is contained in:
@@ -48,11 +48,12 @@ import { getDefaultTooltip } from '../utils/tooltip';
|
||||
import { Refs } from '../types';
|
||||
import { getColtypesMapping } from '../utils/series';
|
||||
|
||||
const setIntervalBoundsAndColors = (
|
||||
export const getIntervalBoundsAndColors = (
|
||||
intervals: string,
|
||||
intervalColorIndices: string,
|
||||
colorFn: CategoricalColorScale,
|
||||
normalizer: number,
|
||||
min: number,
|
||||
max: number,
|
||||
): Array<[number, string]> => {
|
||||
let intervalBoundsNonNormalized;
|
||||
let intervalColorIndicesArray;
|
||||
@@ -65,7 +66,7 @@ const setIntervalBoundsAndColors = (
|
||||
}
|
||||
|
||||
const intervalBounds = intervalBoundsNonNormalized.map(
|
||||
bound => bound / normalizer,
|
||||
bound => (bound - min) / (max - min),
|
||||
);
|
||||
const intervalColors = intervalColorIndicesArray.map(
|
||||
ind => colorFn.colors[(ind - 1) % colorFn.colors.length],
|
||||
@@ -221,12 +222,12 @@ export default function transformProps(
|
||||
const axisLabelLength = Math.max(
|
||||
...axisLabels.map(label => numberFormatter(label).length).concat([1]),
|
||||
);
|
||||
const normalizer = max;
|
||||
const intervalBoundsAndColors = setIntervalBoundsAndColors(
|
||||
const intervalBoundsAndColors = getIntervalBoundsAndColors(
|
||||
intervals,
|
||||
intervalColorIndices,
|
||||
colorFn,
|
||||
normalizer,
|
||||
min,
|
||||
max,
|
||||
);
|
||||
const splitLineDistance =
|
||||
axisLineWidth + splitLineLength + OFFSETS.ticksFromLine;
|
||||
|
||||
Reference in New Issue
Block a user