mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TimeSeries: Don't show y axis when visualisation is hidden (#53671)
* TimeSeries: Don't show y axis when visualisation is hidden * Update snapshot * make scale ranger return nulls for minMax when no visible data exists on scale * drop unneeded change * remove explicit axis.show Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
parent
10e6eac632
commit
86de94cbfa
@ -41,8 +41,8 @@ Object {
|
|||||||
},
|
},
|
||||||
"labelGap": 0,
|
"labelGap": 0,
|
||||||
"rotate": undefined,
|
"rotate": undefined,
|
||||||
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
|
"scale": "__fixed/na-na/na-na/auto/linear/na",
|
||||||
"show": false,
|
"show": true,
|
||||||
"side": 3,
|
"side": 3,
|
||||||
"size": [Function],
|
"size": [Function],
|
||||||
"space": [Function],
|
"space": [Function],
|
||||||
@ -79,7 +79,7 @@ Object {
|
|||||||
"key": "__global_",
|
"key": "__global_",
|
||||||
"scales": Array [
|
"scales": Array [
|
||||||
"x",
|
"x",
|
||||||
"__fixed/na-na/na-na/auto/linear/na/false",
|
"__fixed/na-na/na-na/auto/linear/na",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -87,7 +87,7 @@ Object {
|
|||||||
"mode": 1,
|
"mode": 1,
|
||||||
"padding": undefined,
|
"padding": undefined,
|
||||||
"scales": Object {
|
"scales": Object {
|
||||||
"__fixed/na-na/na-na/auto/linear/na/false": Object {
|
"__fixed/na-na/na-na/auto/linear/na": Object {
|
||||||
"auto": true,
|
"auto": true,
|
||||||
"dir": 1,
|
"dir": 1,
|
||||||
"distr": 1,
|
"distr": 1,
|
||||||
@ -125,7 +125,7 @@ Object {
|
|||||||
"stroke": "#ff0000",
|
"stroke": "#ff0000",
|
||||||
},
|
},
|
||||||
"pxAlign": undefined,
|
"pxAlign": undefined,
|
||||||
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
|
"scale": "__fixed/na-na/na-na/auto/linear/na",
|
||||||
"show": true,
|
"show": true,
|
||||||
"spanGaps": false,
|
"spanGaps": false,
|
||||||
"stroke": "#ff0000",
|
"stroke": "#ff0000",
|
||||||
@ -148,7 +148,7 @@ Object {
|
|||||||
"stroke": "#ff0000",
|
"stroke": "#ff0000",
|
||||||
},
|
},
|
||||||
"pxAlign": undefined,
|
"pxAlign": undefined,
|
||||||
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
|
"scale": "__fixed/na-na/na-na/auto/linear/na",
|
||||||
"show": true,
|
"show": true,
|
||||||
"spanGaps": false,
|
"spanGaps": false,
|
||||||
"stroke": "#ff0000",
|
"stroke": "#ff0000",
|
||||||
@ -171,7 +171,7 @@ Object {
|
|||||||
"stroke": "#ff0000",
|
"stroke": "#ff0000",
|
||||||
},
|
},
|
||||||
"pxAlign": undefined,
|
"pxAlign": undefined,
|
||||||
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
|
"scale": "__fixed/na-na/na-na/auto/linear/na",
|
||||||
"show": true,
|
"show": true,
|
||||||
"spanGaps": false,
|
"spanGaps": false,
|
||||||
"stroke": "#ff0000",
|
"stroke": "#ff0000",
|
||||||
@ -194,7 +194,7 @@ Object {
|
|||||||
"stroke": "#ff0000",
|
"stroke": "#ff0000",
|
||||||
},
|
},
|
||||||
"pxAlign": undefined,
|
"pxAlign": undefined,
|
||||||
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
|
"scale": "__fixed/na-na/na-na/auto/linear/na",
|
||||||
"show": true,
|
"show": true,
|
||||||
"spanGaps": false,
|
"spanGaps": false,
|
||||||
"stroke": "#ff0000",
|
"stroke": "#ff0000",
|
||||||
@ -217,7 +217,7 @@ Object {
|
|||||||
"stroke": "#ff0000",
|
"stroke": "#ff0000",
|
||||||
},
|
},
|
||||||
"pxAlign": undefined,
|
"pxAlign": undefined,
|
||||||
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
|
"scale": "__fixed/na-na/na-na/auto/linear/na",
|
||||||
"show": true,
|
"show": true,
|
||||||
"spanGaps": false,
|
"spanGaps": false,
|
||||||
"stroke": "#ff0000",
|
"stroke": "#ff0000",
|
||||||
|
@ -151,9 +151,7 @@ export function buildScaleKey(config: FieldConfig<GraphFieldConfig>) {
|
|||||||
|
|
||||||
const scaleLabel = Boolean(config.custom?.axisLabel) ? config.custom!.axisLabel : defaultPart;
|
const scaleLabel = Boolean(config.custom?.axisLabel) ? config.custom!.axisLabel : defaultPart;
|
||||||
|
|
||||||
const shouldHideFromViz = Boolean(config.custom?.hideFrom?.viz);
|
return `${scaleUnit}/${scaleRange}/${scaleSoftRange}/${scalePlacement}/${scaleDistribution}/${scaleLabel}`;
|
||||||
|
|
||||||
return `${scaleUnit}/${scaleRange}/${scaleSoftRange}/${scalePlacement}/${scaleDistribution}/${scaleLabel}/${shouldHideFromViz}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getScaleDistributionPart(config: ScaleDistributionConfig) {
|
function getScaleDistributionPart(config: ScaleDistributionConfig) {
|
||||||
|
@ -272,7 +272,6 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{
|
|||||||
formatValue: (v, decimals) => formattedValueToString(fmt(v, config.decimals ?? decimals)),
|
formatValue: (v, decimals) => formattedValueToString(fmt(v, config.decimals ?? decimals)),
|
||||||
theme,
|
theme,
|
||||||
grid: { show: customConfig.axisGridShow },
|
grid: { show: customConfig.axisGridShow },
|
||||||
show: customConfig.hideFrom?.viz === false,
|
|
||||||
...axisColorOpts,
|
...axisColorOpts,
|
||||||
},
|
},
|
||||||
field
|
field
|
||||||
|
@ -74,11 +74,16 @@ export class UPlotScaleBuilder extends PlotConfigBuilder<ScaleProps, Scale> {
|
|||||||
let hardMaxOnly = softMax == null && hardMax != null;
|
let hardMaxOnly = softMax == null && hardMax != null;
|
||||||
|
|
||||||
// uPlot range function
|
// uPlot range function
|
||||||
const rangeFn = (u: uPlot, dataMin: number, dataMax: number, scaleKey: string) => {
|
const rangeFn = (u: uPlot, dataMin: number | null, dataMax: number | null, scaleKey: string) => {
|
||||||
const scale = u.scales[scaleKey];
|
const scale = u.scales[scaleKey];
|
||||||
|
|
||||||
let minMax: uPlot.Range.MinMax = [dataMin, dataMax];
|
let minMax: uPlot.Range.MinMax = [dataMin, dataMax];
|
||||||
|
|
||||||
|
// happens when all series on a scale are `show: false`, re-returning nulls will auto-disable axis
|
||||||
|
if (dataMin == null || dataMax == null) {
|
||||||
|
return minMax;
|
||||||
|
}
|
||||||
|
|
||||||
if (scale.distr === 1 || scale.distr === 2) {
|
if (scale.distr === 1 || scale.distr === 2) {
|
||||||
if (centeredZero) {
|
if (centeredZero) {
|
||||||
let absMin = Math.abs(dataMin);
|
let absMin = Math.abs(dataMin);
|
||||||
|
Loading…
Reference in New Issue
Block a user