drawMACD method

void drawMACD(
  1. MACDEntity curPoint,
  2. Canvas canvas,
  3. double curX,
  4. MACDEntity lastPoint,
  5. double lastX,
)

Implementation

void drawMACD(MACDEntity curPoint, Canvas canvas, double curX,
    MACDEntity lastPoint, double lastX) {
  final macd = curPoint.macd ?? 0;
  double macdY = getY(macd);
  double r = mMACDWidth / 2;
  double zeroy = getY(0);
  if (macd > 0) {
    canvas.drawRect(Rect.fromLTRB(curX - r, macdY, curX + r, zeroy),
        chartPaint..color = this.chartColors.upColor);
  } else {
    canvas.drawRect(Rect.fromLTRB(curX - r, zeroy, curX + r, macdY),
        chartPaint..color = this.chartColors.dnColor);
  }
  if (lastPoint.dif != 0) {
    drawLine(lastPoint.dif, curPoint.dif, canvas, lastX, curX,
        this.chartColors.difColor);
  }
  if (lastPoint.dea != 0) {
    drawLine(lastPoint.dea, curPoint.dea, canvas, lastX, curX,
        this.chartColors.deaColor);
  }
}