mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 12:44:10 -06:00
XYChart: Fix axis range and scale overrides (#70605)
This commit is contained in:
parent
53231cb68d
commit
fe45dc9f27
@ -157,7 +157,7 @@ export class UPlotScaleBuilder extends PlotConfigBuilder<ScaleProps, Scale> {
|
||||
let minMax: uPlot.Range.MinMax = [dataMin, dataMax];
|
||||
|
||||
// don't pad numeric x scales
|
||||
if (scaleKey === 'x' && !isTime) {
|
||||
if (scaleKey === 'x' && !isTime && distr === ScaleDistribution.Linear) {
|
||||
return minMax;
|
||||
}
|
||||
|
||||
|
@ -601,22 +601,33 @@ const prepConfig = (
|
||||
const frames = getData();
|
||||
let xField = scatterSeries[0].x(scatterSeries[0].frame(frames));
|
||||
|
||||
let config = xField.config;
|
||||
let customConfig = config.custom;
|
||||
let scaleDistr = customConfig?.scaleDistribution;
|
||||
|
||||
builder.addScale({
|
||||
scaleKey: 'x',
|
||||
isTime: false,
|
||||
orientation: ScaleOrientation.Horizontal,
|
||||
direction: ScaleDirection.Right,
|
||||
range: (u, dataMin, dataMax) => [xField.config.min ?? dataMin, xField.config.max ?? dataMax],
|
||||
distribution: scaleDistr?.type,
|
||||
log: scaleDistr?.log,
|
||||
linearThreshold: scaleDistr?.linearThreshold,
|
||||
min: config.min,
|
||||
max: config.max,
|
||||
softMin: customConfig?.axisSoftMin,
|
||||
softMax: customConfig?.axisSoftMax,
|
||||
centeredZero: customConfig?.axisCenteredZero,
|
||||
decimals: config.decimals,
|
||||
});
|
||||
|
||||
// why does this fall back to '' instead of null or undef?
|
||||
let xAxisLabel = xField.config.custom.axisLabel;
|
||||
let xAxisLabel = customConfig.axisLabel;
|
||||
|
||||
builder.addAxis({
|
||||
scaleKey: 'x',
|
||||
placement:
|
||||
xField.config.custom?.axisPlacement !== AxisPlacement.Hidden ? AxisPlacement.Bottom : AxisPlacement.Hidden,
|
||||
show: xField.config.custom?.axisPlacement !== AxisPlacement.Hidden,
|
||||
placement: customConfig?.axisPlacement !== AxisPlacement.Hidden ? AxisPlacement.Bottom : AxisPlacement.Hidden,
|
||||
show: customConfig?.axisPlacement !== AxisPlacement.Hidden,
|
||||
theme,
|
||||
label:
|
||||
xAxisLabel == null || xAxisLabel === ''
|
||||
@ -635,23 +646,33 @@ const prepConfig = (
|
||||
//const lineWidth = s.lineWidth;
|
||||
|
||||
let scaleKey = field.config.unit ?? 'y';
|
||||
let config = field.config;
|
||||
let customConfig = config.custom;
|
||||
let scaleDistr = customConfig?.scaleDistribution;
|
||||
|
||||
builder.addScale({
|
||||
scaleKey,
|
||||
orientation: ScaleOrientation.Vertical,
|
||||
direction: ScaleDirection.Up,
|
||||
max: field.config.max,
|
||||
min: field.config.min,
|
||||
distribution: scaleDistr?.type,
|
||||
log: scaleDistr?.log,
|
||||
linearThreshold: scaleDistr?.linearThreshold,
|
||||
min: config.min,
|
||||
max: config.max,
|
||||
softMin: customConfig?.axisSoftMin,
|
||||
softMax: customConfig?.axisSoftMax,
|
||||
centeredZero: customConfig?.axisCenteredZero,
|
||||
decimals: config.decimals,
|
||||
});
|
||||
|
||||
if (field.config.custom?.axisPlacement !== AxisPlacement.Hidden) {
|
||||
if (customConfig?.axisPlacement !== AxisPlacement.Hidden) {
|
||||
// why does this fall back to '' instead of null or undef?
|
||||
let yAxisLabel = field.config.custom?.axisLabel;
|
||||
let yAxisLabel = customConfig?.axisLabel;
|
||||
|
||||
builder.addAxis({
|
||||
scaleKey,
|
||||
theme,
|
||||
placement: field.config.custom?.axisPlacement,
|
||||
placement: customConfig?.axisPlacement,
|
||||
label:
|
||||
yAxisLabel == null || yAxisLabel === ''
|
||||
? getFieldDisplayName(field, scatterSeries[si].frame(frames), frames)
|
||||
@ -676,7 +697,7 @@ const prepConfig = (
|
||||
scaleKey: '', // facets' scales used (above)
|
||||
lineColor: lineColor as string,
|
||||
fillColor: alpha(pointColor, 0.5),
|
||||
show: !field.config.custom.hideFrom?.viz,
|
||||
show: !customConfig.hideFrom?.viz,
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user