Colors: rename getThresholdRange() -> getGradientRange() (#38688)

* Colors: use visible y scale range for non-threshold gradients schemes

* rename instead
This commit is contained in:
Leon Sorokin 2021-08-30 15:04:02 -05:00 committed by GitHub
parent a0108a1e5b
commit 05e5b67a99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import { GrafanaTheme2, ThresholdsConfig, ThresholdsMode } from '@grafana/data'; import { GrafanaTheme2, ThresholdsConfig, ThresholdsMode } from '@grafana/data';
import { GraphThresholdsStyleConfig, GraphTresholdsStyleMode } from '@grafana/schema'; import { GraphThresholdsStyleConfig, GraphTresholdsStyleMode } from '@grafana/schema';
import { getThresholdRange, GradientDirection, scaleGradient } from './gradientFills'; import { getGradientRange, GradientDirection, scaleGradient } from './gradientFills';
import tinycolor from 'tinycolor2'; import tinycolor from 'tinycolor2';
export interface UPlotThresholdOptions { export interface UPlotThresholdOptions {
@ -28,7 +28,7 @@ export function getThresholdsDrawHook(options: UPlotThresholdOptions) {
let { steps, mode } = thresholds; let { steps, mode } = thresholds;
if (mode === ThresholdsMode.Percentage) { if (mode === ThresholdsMode.Percentage) {
let [min, max] = getThresholdRange(u, scaleKey, hardMin, hardMax, softMin, softMax); let [min, max] = getGradientRange(u, scaleKey, hardMin, hardMax, softMin, softMax);
let range = max - min; let range = max - min;
steps = steps.map((step) => ({ steps = steps.map((step) => ({

View File

@ -172,7 +172,7 @@ export function getDataRange(plot: uPlot, scaleKey: string) {
return [min, max]; return [min, max];
} }
export function getThresholdRange( export function getGradientRange(
u: uPlot, u: uPlot,
scaleKey: string, scaleKey: string,
hardMin?: number | null, hardMin?: number | null,
@ -224,7 +224,7 @@ export function getScaleGradientFn(
); );
gradient = scaleGradient(plot, scaleKey, GradientDirection.Up, valueStops, true); gradient = scaleGradient(plot, scaleKey, GradientDirection.Up, valueStops, true);
} else { } else {
const [min, max] = getThresholdRange(plot, scaleKey, hardMin, hardMax, softMin, softMax); const [min, max] = getGradientRange(plot, scaleKey, hardMin, hardMax, softMin, softMax);
const range = max - min; const range = max - min;
const valueStops = thresholds.steps.map( const valueStops = thresholds.steps.map(
(step) => (step) =>
@ -237,7 +237,7 @@ export function getScaleGradientFn(
} }
} else if (colorMode.getColors) { } else if (colorMode.getColors) {
const colors = colorMode.getColors(theme); const colors = colorMode.getColors(theme);
const [min, max] = getThresholdRange(plot, scaleKey, hardMin, hardMax, softMin, softMax); const [min, max] = getGradientRange(plot, scaleKey, hardMin, hardMax, softMin, softMax);
const range = max - min; const range = max - min;
const valueStops = colors.map( const valueStops = colors.map(
(color, i) => (color, i) =>