drawVerticalText method
void
drawVerticalText({
- required Canvas canvas,
- required TextStyle style,
- required double maxValue,
- required double minValue,
- required int fixedLength,
- required Rect chartRect,
override
Implementation
@override
void drawVerticalText({
required Canvas canvas,
required TextStyle style,
required double maxValue,
required double minValue,
required int fixedLength,
required Rect chartRect,
}) {
List<int> rangeValue = [80, 20];
final spaceRange = maxValue - minValue;
for (int i = 0; i < rangeValue.length; ++i) {
final value = rangeValue[i];
if (value < minValue || value > maxValue) continue;
TextPainter tp = TextPainter(
text: TextSpan(
text: value.toString(),
style: style,
),
textDirection: TextDirection.ltr,
);
tp.layout();
final ratio = (value - minValue) / spaceRange;
final x = chartRect.width - tp.width;
final y = chartRect.bottom - ratio * chartRect.height - tp.height / 2;
tp.paint(
canvas,
Offset(x, y.clamp(chartRect.top, chartRect.bottom - tp.height)),
);
}
}