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:
Zoltán Bedi 2022-08-18 15:26:40 +02:00 committed by GitHub
parent 10e6eac632
commit 86de94cbfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 14 deletions

View File

@ -41,8 +41,8 @@ Object {
},
"labelGap": 0,
"rotate": undefined,
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
"show": false,
"scale": "__fixed/na-na/na-na/auto/linear/na",
"show": true,
"side": 3,
"size": [Function],
"space": [Function],
@ -79,7 +79,7 @@ Object {
"key": "__global_",
"scales": Array [
"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,
"padding": undefined,
"scales": Object {
"__fixed/na-na/na-na/auto/linear/na/false": Object {
"__fixed/na-na/na-na/auto/linear/na": Object {
"auto": true,
"dir": 1,
"distr": 1,
@ -125,7 +125,7 @@ Object {
"stroke": "#ff0000",
},
"pxAlign": undefined,
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
"scale": "__fixed/na-na/na-na/auto/linear/na",
"show": true,
"spanGaps": false,
"stroke": "#ff0000",
@ -148,7 +148,7 @@ Object {
"stroke": "#ff0000",
},
"pxAlign": undefined,
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
"scale": "__fixed/na-na/na-na/auto/linear/na",
"show": true,
"spanGaps": false,
"stroke": "#ff0000",
@ -171,7 +171,7 @@ Object {
"stroke": "#ff0000",
},
"pxAlign": undefined,
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
"scale": "__fixed/na-na/na-na/auto/linear/na",
"show": true,
"spanGaps": false,
"stroke": "#ff0000",
@ -194,7 +194,7 @@ Object {
"stroke": "#ff0000",
},
"pxAlign": undefined,
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
"scale": "__fixed/na-na/na-na/auto/linear/na",
"show": true,
"spanGaps": false,
"stroke": "#ff0000",
@ -217,7 +217,7 @@ Object {
"stroke": "#ff0000",
},
"pxAlign": undefined,
"scale": "__fixed/na-na/na-na/auto/linear/na/false",
"scale": "__fixed/na-na/na-na/auto/linear/na",
"show": true,
"spanGaps": false,
"stroke": "#ff0000",

View File

@ -151,9 +151,7 @@ export function buildScaleKey(config: FieldConfig<GraphFieldConfig>) {
const scaleLabel = Boolean(config.custom?.axisLabel) ? config.custom!.axisLabel : defaultPart;
const shouldHideFromViz = Boolean(config.custom?.hideFrom?.viz);
return `${scaleUnit}/${scaleRange}/${scaleSoftRange}/${scalePlacement}/${scaleDistribution}/${scaleLabel}/${shouldHideFromViz}`;
return `${scaleUnit}/${scaleRange}/${scaleSoftRange}/${scalePlacement}/${scaleDistribution}/${scaleLabel}`;
}
function getScaleDistributionPart(config: ScaleDistributionConfig) {

View File

@ -272,7 +272,6 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{
formatValue: (v, decimals) => formattedValueToString(fmt(v, config.decimals ?? decimals)),
theme,
grid: { show: customConfig.axisGridShow },
show: customConfig.hideFrom?.viz === false,
...axisColorOpts,
},
field

View File

@ -74,11 +74,16 @@ export class UPlotScaleBuilder extends PlotConfigBuilder<ScaleProps, Scale> {
let hardMaxOnly = softMax == null && hardMax != null;
// 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];
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 (centeredZero) {
let absMin = Math.abs(dataMin);