mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
GraphNG: fix y axis autosizing (#37464)
This commit is contained in:
parent
75c8bd26fc
commit
0d2cd90150
@ -71,7 +71,6 @@ export class UPlotAxisBuilder extends PlotConfigBuilder<AxisProps, Axis> {
|
||||
size: this.props.size ?? calculateAxisSize,
|
||||
gap,
|
||||
|
||||
// @ts-ignore (TODO: remove once uPlot adds this in 1.6.15)
|
||||
labelGap: 0,
|
||||
|
||||
grid: {
|
||||
@ -94,7 +93,6 @@ export class UPlotAxisBuilder extends PlotConfigBuilder<AxisProps, Axis> {
|
||||
config.label = label;
|
||||
config.labelSize = fontSize + labelPad;
|
||||
config.labelFont = font;
|
||||
// @ts-ignore (TODO: remove once uPlot adds this in 1.6.15)
|
||||
config.labelGap = labelPad;
|
||||
}
|
||||
|
||||
@ -146,8 +144,7 @@ function calculateAxisSize(self: uPlot, values: string[], axisIdx: number) {
|
||||
axisSize += axis!.gap! + fontSize;
|
||||
} else if (values?.length) {
|
||||
let longestValue = values.reduce((acc, value) => (value.length > acc.length ? value : acc), '');
|
||||
// @ts-ignore (TODO: remove axis!.labelGap! once uPlot adds this in 1.6.15)
|
||||
axisSize += axis!.gap! + axis!.labelGap! + measureText(longestValue, fontSize).width;
|
||||
axisSize += axis!.gap! + axis!.labelGap! + measureText('0'.repeat(longestValue.length), fontSize).width;
|
||||
}
|
||||
|
||||
return Math.ceil(axisSize);
|
||||
|
Loading…
Reference in New Issue
Block a user