From 05e5b67a996cf4148f9385627fe6bacc3a1cb2f4 Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Mon, 30 Aug 2021 15:04:02 -0500 Subject: [PATCH] Colors: rename getThresholdRange() -> getGradientRange() (#38688) * Colors: use visible y scale range for non-threshold gradients schemes * rename instead --- .../src/components/uPlot/config/UPlotThresholds.ts | 4 ++-- .../grafana-ui/src/components/uPlot/config/gradientFills.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/grafana-ui/src/components/uPlot/config/UPlotThresholds.ts b/packages/grafana-ui/src/components/uPlot/config/UPlotThresholds.ts index d431c91976a..7c34e883de3 100644 --- a/packages/grafana-ui/src/components/uPlot/config/UPlotThresholds.ts +++ b/packages/grafana-ui/src/components/uPlot/config/UPlotThresholds.ts @@ -1,6 +1,6 @@ import { GrafanaTheme2, ThresholdsConfig, ThresholdsMode } from '@grafana/data'; import { GraphThresholdsStyleConfig, GraphTresholdsStyleMode } from '@grafana/schema'; -import { getThresholdRange, GradientDirection, scaleGradient } from './gradientFills'; +import { getGradientRange, GradientDirection, scaleGradient } from './gradientFills'; import tinycolor from 'tinycolor2'; export interface UPlotThresholdOptions { @@ -28,7 +28,7 @@ export function getThresholdsDrawHook(options: UPlotThresholdOptions) { let { steps, mode } = thresholds; 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; steps = steps.map((step) => ({ diff --git a/packages/grafana-ui/src/components/uPlot/config/gradientFills.ts b/packages/grafana-ui/src/components/uPlot/config/gradientFills.ts index 88bd1d617a0..06a838efee9 100644 --- a/packages/grafana-ui/src/components/uPlot/config/gradientFills.ts +++ b/packages/grafana-ui/src/components/uPlot/config/gradientFills.ts @@ -172,7 +172,7 @@ export function getDataRange(plot: uPlot, scaleKey: string) { return [min, max]; } -export function getThresholdRange( +export function getGradientRange( u: uPlot, scaleKey: string, hardMin?: number | null, @@ -224,7 +224,7 @@ export function getScaleGradientFn( ); gradient = scaleGradient(plot, scaleKey, GradientDirection.Up, valueStops, true); } 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 valueStops = thresholds.steps.map( (step) => @@ -237,7 +237,7 @@ export function getScaleGradientFn( } } else if (colorMode.getColors) { 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 valueStops = colors.map( (color, i) =>