Statetimeline/TimeSeries/BarChart: Limit y label width to 40% of visualiation width (#42350)

pull/42370/head
Torkel Ödegaard 4 years ago committed by GitHub
parent 802ffa3f03
commit 820aa3ac59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/grafana-ui/src/components/uPlot/config/UPlotAxisBuilder.ts

@ -75,7 +75,10 @@ export class UPlotAxisBuilder extends PlotConfigBuilder<AxisProps, Axis> {
(acc, value) => Math.max(acc, measureText(value, UPLOT_AXIS_FONT_SIZE).width),
0
);
axisSize += axis!.gap! + axis!.labelGap! + maxTextWidth;
// limit y tick label width to 40% of visualization
const textWidthWithLimit = Math.min(self.width * 0.4, maxTextWidth);
// Not sure why this += and not normal assignment
axisSize += axis!.gap! + axis!.labelGap! + textWidthWithLimit;
}
return Math.ceil(axisSize);

Loading…
Cancel
Save