From af9839628554d0d6fe46d3ffb9aae61a8a2f16ff Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 16 Jun 2023 12:20:18 -0400 Subject: [PATCH] [v10.0.x] XYChart/Trend: Fix min/max and units/decimals X field overrides (#70261) XYChart/Trend: Fix min/max and units/decimals x-field overrides (#70214) (cherry picked from commit 66b0e6b77f84239e7a43e215e7163481c834eeb7) Co-authored-by: Leon Sorokin --- packages/grafana-ui/src/components/TimeSeries/utils.ts | 2 ++ public/app/plugins/panel/trend/TrendPanel.tsx | 4 +--- public/app/plugins/panel/xychart/scatter.ts | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/grafana-ui/src/components/TimeSeries/utils.ts b/packages/grafana-ui/src/components/TimeSeries/utils.ts index 6fb3f50ce8c..7d5b8767b28 100644 --- a/packages/grafana-ui/src/components/TimeSeries/utils.ts +++ b/packages/grafana-ui/src/components/TimeSeries/utils.ts @@ -181,6 +181,7 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{ scaleKey: xScaleKey, orientation: ScaleOrientation.Horizontal, direction: ScaleDirection.Right, + range: (u, dataMin, dataMax) => [xField.config.min ?? dataMin, xField.config.max ?? dataMax], }); builder.addAxis({ @@ -190,6 +191,7 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{ label: xField.config.custom?.axisLabel, theme, grid: { show: xField.config.custom?.axisGridShow }, + formatValue: (v, decimals) => formattedValueToString(xField.display!(v, decimals)), }); } diff --git a/public/app/plugins/panel/trend/TrendPanel.tsx b/public/app/plugins/panel/trend/TrendPanel.tsx index 30b02975154..3ae9c75b899 100644 --- a/public/app/plugins/panel/trend/TrendPanel.tsx +++ b/public/app/plugins/panel/trend/TrendPanel.tsx @@ -92,9 +92,7 @@ export const TrendPanel = ({ options={options} > {(config, alignedDataFrame) => { - if ( - alignedDataFrame.fields.filter((f) => f.config.links !== undefined && f.config.links.length > 0).length > 0 - ) { + if (alignedDataFrame.fields.some((f) => Boolean(f.config.links?.length))) { alignedDataFrame = regenerateLinksSupplier(alignedDataFrame, info.frames!, replaceVariables, timeZone); } diff --git a/public/app/plugins/panel/xychart/scatter.ts b/public/app/plugins/panel/xychart/scatter.ts index 5d335eaf6b5..83f371507e8 100644 --- a/public/app/plugins/panel/xychart/scatter.ts +++ b/public/app/plugins/panel/xychart/scatter.ts @@ -604,8 +604,7 @@ const prepConfig = ( isTime: false, orientation: ScaleOrientation.Horizontal, direction: ScaleDirection.Right, - min: xField.config.min, - max: xField.config.max, + range: (u, dataMin, dataMax) => [xField.config.min ?? dataMin, xField.config.max ?? dataMax], }); // why does this fall back to '' instead of null or undef?