drawNowPrice method

  1. @override
void drawNowPrice(
  1. Canvas canvas
)
override

Implementation

@override
void drawNowPrice(Canvas canvas) {
  if (datas == null) {
    return;
  }
  double value = datas!.last.close;
  double y = getMainY(value);
  if (y > getMainY(mMainLowMinValue) || y < getMainY(mMainHighMaxValue)) {
    return;
  }
  nowPricePaint
    ..color = value >= datas!.last.open
        ? this.chartColors.nowPriceUpColor
        : this.chartColors.nowPriceDnColor;
  double startX = 0;
  final max = -mTranslateX + mWidth / scaleX;
  final space =
      this.chartStyle.nowPriceLineSpan + this.chartStyle.nowPriceLineLength;
  while (startX < max) {
    canvas.drawLine(
        Offset(startX, y),
        Offset(startX + this.chartStyle.nowPriceLineLength, y),
        nowPricePaint);
    startX += space;
  }
  TextPainter tp = getTextPainter(
      NumberUtil.formatNumber(double.parse(value.toStringAsFixed(0))),
      this.chartColors.nowPriceTextColor);
  double left = 0;
  double top = y - tp.height / 2;
  canvas.drawRect(
      Rect.fromLTRB(left, top - 3, left + tp.width + 5, top + tp.height + 3),
      nowPricePaint);
  tp.paint(canvas, Offset(0, top));
}