Skip to content

Commit

Permalink
[v10.0.x] XYChart/Trend: Fix min/max and units/decimals X field overr…
Browse files Browse the repository at this point in the history
…ides (#70261)

XYChart/Trend: Fix min/max and units/decimals x-field overrides (#70214)

(cherry picked from commit 66b0e6b)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
  • Loading branch information
grafanabot and leeoniya committed Jun 16, 2023
1 parent edd4faf commit af98396
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/grafana-ui/src/components/TimeSeries/utils.ts
Expand Up @@ -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({
Expand All @@ -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)),
});
}

Expand Down
4 changes: 1 addition & 3 deletions public/app/plugins/panel/trend/TrendPanel.tsx
Expand Up @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions public/app/plugins/panel/xychart/scatter.ts
Expand Up @@ -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?
Expand Down

0 comments on commit af98396

Please sign in to comment.