measureVerticallyDrawnTicks method

  1. @override
ViewMeasuredSizes measureVerticallyDrawnTicks(
  1. List<Tick<D>> ticks,
  2. int maxWidth,
  3. int maxHeight, {
  4. bool collision = false,
})
override

Returns measurement of ticks drawn vertically.

Implementation

@override
ViewMeasuredSizes measureVerticallyDrawnTicks(
  List<Tick<D>> ticks,
  int maxWidth,
  int maxHeight, {
  bool collision = false,
}) {
  // TODO: Add spacing to account for the distance between the
  // text and the axis baseline (even if it isn't drawn).

  final maxHorizontalSliceWidth = ticks.fold(0, (prevMax, tick) {
    final labelElements = splitLabel(tick.textElement!);

    return max(
      prevMax.toDouble(),
      calculateWidthForRotatedLabel(
            labelRotation(collision: collision),
            getLabelHeight(labelElements),
            getLabelWidth(labelElements),
          ) +
          labelOffsetFromAxisPx(collision: collision),
      //TODO: possible precision loss
    ).toInt();
  });

  return ViewMeasuredSizes(
    preferredWidth: maxHorizontalSliceWidth,
    preferredHeight: maxHeight,
  );
}