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

This commit is contained in:
Torkel Ödegaard 2021-11-26 14:15:57 +01:00 committed by GitHub
parent 802ffa3f03
commit 820aa3ac59
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);