drawGridVerticalText method
void
drawGridVerticalText({})
绘制垂直文字
Implementation
void drawGridVerticalText({
required Canvas canvas,
required double canvasWidth,
required double canvasHeight,
required double value,
required double dy,
required TextStyle style,
double? lastClose,
}) {
if (dy.isNaN) {
return;
}
String maxText = Utils.toStringAsFixed(value);
TextPainter painter = createText(text: maxText, style: style);
double y;
if (dy + painter.height > canvasHeight) {
y = canvasHeight - painter.height;
} else {
y = dy - painter.height;
if (y < 0) {
y = 0;
}
}
painter.paint(canvas, Offset(0, y));
///// 绘制涨跌比率文字
if (lastClose != null) {
String maxRatioText = Utils.calcStockPriceRatio(lastClose, value);
TextPainter painter = createText(text: maxRatioText, style: style);
painter.paint(canvas, Offset(canvasWidth - painter.width, y));
}
}