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

(cherry picked from commit 820aa3ac59)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
This commit is contained in:
Grot (@grafanabot) 2021-11-26 08:32:49 -05:00 committed by GitHub
parent b5960313fb
commit ce0771efea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);