drawCrossLine method

void drawCrossLine(
  1. Canvas canvas,
  2. Size size
)
override

画交叉线

Implementation

void drawCrossLine(Canvas canvas, Size size) {
  var index = calculateSelectedX(selectX);
  KLineEntity point = getItem(index);
  Paint paintY = Paint()
    ..color = this.chartColors.vCrossColor
    ..strokeWidth = this.chartStyle.vCrossWidth
    ..isAntiAlias = true;
  double x = getX(index);
  double y = getMainY(point.close);
  // k线图竖线
  canvas.drawLine(Offset(x, mTopPadding),
      Offset(x, size.height - mBottomPadding), paintY);

  Paint paintX = Paint()
    ..color = this.chartColors.hCrossColor
    ..strokeWidth = this.chartStyle.hCrossWidth
    ..isAntiAlias = true;
  // k线图横线
  canvas.drawLine(Offset(-mTranslateX, y),
      Offset(-mTranslateX + mWidth / scaleX, y), paintX);
  if (scaleX >= 1) {
    canvas.drawOval(
        Rect.fromCenter(
            center: Offset(x, y), height: 2.0 * scaleX, width: 2.0),
        paintX);
  } else {
    canvas.drawOval(
        Rect.fromCenter(
            center: Offset(x, y), height: 2.0, width: 2.0 / scaleX),
        paintX);
  }
}