mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
XYChart: Fix numerous axis options (#75044)
This commit is contained in:
parent
e83054386b
commit
780b60dc81
@ -32,11 +32,6 @@ exports[`GraphNG utils preparePlotConfigBuilder 1`] = `
|
||||
"values": [Function],
|
||||
},
|
||||
{
|
||||
"border": {
|
||||
"show": false,
|
||||
"stroke": "rgb(204, 204, 220)",
|
||||
"width": 1,
|
||||
},
|
||||
"filter": undefined,
|
||||
"font": "12px "Inter", "Helvetica", "Arial", sans-serif",
|
||||
"gap": 5,
|
||||
|
@ -180,8 +180,12 @@ export class UPlotAxisBuilder extends PlotConfigBuilder<AxisProps, Axis> {
|
||||
incrs,
|
||||
};
|
||||
|
||||
if (border != null) {
|
||||
config.border = border;
|
||||
if (border?.show) {
|
||||
config.border = {
|
||||
stroke: color ?? theme.colors.text.primary,
|
||||
width: 1 / devicePixelRatio,
|
||||
...border,
|
||||
};
|
||||
}
|
||||
|
||||
if (label != null && label.length > 0) {
|
||||
|
@ -65,6 +65,7 @@ export function addAxisConfig(
|
||||
{ value: false, label: 'Off' },
|
||||
],
|
||||
},
|
||||
showIf: (c) => c.axisPlacement !== AxisPlacement.Hidden,
|
||||
})
|
||||
.addRadio({
|
||||
path: 'axisColorMode',
|
||||
@ -77,12 +78,14 @@ export function addAxisConfig(
|
||||
{ value: AxisColorMode.Series, label: 'Series' },
|
||||
],
|
||||
},
|
||||
showIf: (c) => c.axisPlacement !== AxisPlacement.Hidden,
|
||||
})
|
||||
.addBooleanSwitch({
|
||||
path: 'axisShow',
|
||||
name: 'Show axis',
|
||||
path: 'axisShow', // TODO: rename to axisBorderShow
|
||||
name: 'Show border',
|
||||
category,
|
||||
defaultValue: false,
|
||||
showIf: (c) => c.axisPlacement !== AxisPlacement.Hidden,
|
||||
});
|
||||
|
||||
// options for scale range
|
||||
|
@ -622,6 +622,8 @@ const prepConfig = (
|
||||
scaleKey: 'x',
|
||||
placement: customConfig?.axisPlacement !== AxisPlacement.Hidden ? AxisPlacement.Bottom : AxisPlacement.Hidden,
|
||||
show: customConfig?.axisPlacement !== AxisPlacement.Hidden,
|
||||
grid: { show: customConfig?.axisGridShow },
|
||||
border: { show: customConfig?.axisShow },
|
||||
theme,
|
||||
label:
|
||||
xAxisLabel == null || xAxisLabel === ''
|
||||
@ -659,21 +661,23 @@ const prepConfig = (
|
||||
decimals: config.decimals,
|
||||
});
|
||||
|
||||
if (customConfig?.axisPlacement !== AxisPlacement.Hidden) {
|
||||
// why does this fall back to '' instead of null or undef?
|
||||
let yAxisLabel = customConfig?.axisLabel;
|
||||
// why does this fall back to '' instead of null or undef?
|
||||
let yAxisLabel = customConfig?.axisLabel;
|
||||
|
||||
builder.addAxis({
|
||||
scaleKey,
|
||||
theme,
|
||||
placement: customConfig?.axisPlacement,
|
||||
label:
|
||||
yAxisLabel == null || yAxisLabel === ''
|
||||
? getFieldDisplayName(field, scatterSeries[si].frame(frames), frames)
|
||||
: yAxisLabel,
|
||||
formatValue: (v, decimals) => formattedValueToString(field.display!(v, decimals)),
|
||||
});
|
||||
}
|
||||
builder.addAxis({
|
||||
scaleKey,
|
||||
theme,
|
||||
placement: customConfig?.axisPlacement === AxisPlacement.Auto ? AxisPlacement.Left : customConfig?.axisPlacement,
|
||||
show: customConfig?.axisPlacement !== AxisPlacement.Hidden,
|
||||
grid: { show: customConfig?.axisGridShow },
|
||||
border: { show: customConfig?.axisShow },
|
||||
size: customConfig?.axisWidth,
|
||||
label:
|
||||
yAxisLabel == null || yAxisLabel === ''
|
||||
? getFieldDisplayName(field, scatterSeries[si].frame(frames), frames)
|
||||
: yAxisLabel,
|
||||
formatValue: (v, decimals) => formattedValueToString(field.display!(v, decimals)),
|
||||
});
|
||||
|
||||
builder.addSeries({
|
||||
facets: [
|
||||
|
Loading…
Reference in New Issue
Block a user