[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 66b0e6b77f)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2023-06-16 19:20:18 +03:00
committed by GitHub
co-authored by Leon Sorokin
parent edd4faf064
commit af98396285
3 changed files with 4 additions and 5 deletions
@@ -181,6 +181,7 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{
scaleKey: xScaleKey, scaleKey: xScaleKey,
orientation: ScaleOrientation.Horizontal, orientation: ScaleOrientation.Horizontal,
direction: ScaleDirection.Right, direction: ScaleDirection.Right,
range: (u, dataMin, dataMax) => [xField.config.min ?? dataMin, xField.config.max ?? dataMax],
}); });
builder.addAxis({ builder.addAxis({
@@ -190,6 +191,7 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{
label: xField.config.custom?.axisLabel, label: xField.config.custom?.axisLabel,
theme, theme,
grid: { show: xField.config.custom?.axisGridShow }, grid: { show: xField.config.custom?.axisGridShow },
formatValue: (v, decimals) => formattedValueToString(xField.display!(v, decimals)),
}); });
} }
@@ -92,9 +92,7 @@ export const TrendPanel = ({
options={options} options={options}
> >
{(config, alignedDataFrame) => { {(config, alignedDataFrame) => {
if ( if (alignedDataFrame.fields.some((f) => Boolean(f.config.links?.length))) {
alignedDataFrame.fields.filter((f) => f.config.links !== undefined && f.config.links.length > 0).length > 0
) {
alignedDataFrame = regenerateLinksSupplier(alignedDataFrame, info.frames!, replaceVariables, timeZone); alignedDataFrame = regenerateLinksSupplier(alignedDataFrame, info.frames!, replaceVariables, timeZone);
} }
+1 -2
View File
@@ -604,8 +604,7 @@ const prepConfig = (
isTime: false, isTime: false,
orientation: ScaleOrientation.Horizontal, orientation: ScaleOrientation.Horizontal,
direction: ScaleDirection.Right, direction: ScaleDirection.Right,
min: xField.config.min, range: (u, dataMin, dataMax) => [xField.config.min ?? dataMin, xField.config.max ?? dataMax],
max: xField.config.max,
}); });
// why does this fall back to '' instead of null or undef? // why does this fall back to '' instead of null or undef?