drawVerticalText method
void
drawVerticalText(
- dynamic canvas,
- dynamic textStyle,
- int gridRows
)
override
Implementation
@override
void drawVerticalText(canvas, textStyle, int gridRows) {
double rowSpace = chartRect.height / gridRows;
for (var i = 0; i <= gridRows; ++i) {
double value = (gridRows - i) * rowSpace / scaleY + minValue;
TextSpan span = TextSpan(text: "${format(value)}", style: textStyle);
TextPainter tp =
TextPainter(text: span, textDirection: TextDirection.ltr);
tp.layout();
double offsetX;
switch (verticalTextAlignment) {
case VerticalTextAlignment.left:
offsetX = 0;
break;
case VerticalTextAlignment.right:
offsetX = chartRect.width - tp.width;
break;
}
if (i == 0) {
tp.paint(canvas, Offset(offsetX, topPadding));
} else {
tp.paint(
canvas, Offset(offsetX, rowSpace * i - tp.height + topPadding));
}
}
}