updateTickWidth method
void
updateTickWidth(
- List<
Tick< ticks,D> > - int maxWidth,
- int maxHeight,
- AxisOrientation orientation, {
- bool collision = false,
override
Updates max tick width to match fit max size.
Implementation
@override
void updateTickWidth(List<Tick<D>> ticks, int maxWidth, int maxHeight,
AxisOrientation orientation,
{bool collision = false}) {
final isVertical =
orientation != null && orientation == AxisOrientation.right ||
orientation == AxisOrientation.left;
final rotationRelativeToAxis =
labelRotation(collision: collision).toDouble();
final rotationRads =
_degToRad(rotationRelativeToAxis - (isVertical ? 90 : 0)).abs();
final availableSpace = (isVertical ? maxWidth : maxHeight) -
labelOffsetFromAxisPx(collision: collision);
final maxTextWidth = sin(rotationRads) == 0
? null
: (availableSpace / sin(rotationRads)).floor();
for (final tick in ticks) {
if (maxTextWidth != null) {
tick.textElement!.maxWidth = maxTextWidth;
tick.textElement!.maxWidthStrategy = MaxWidthStrategy.ellipsize;
} else {
tick.textElement!.maxWidth = null;
tick.textElement!.maxWidthStrategy = null;
}
}
}