drawCandle method
Implementation
void drawCandle(CandleEntity curPoint, Canvas canvas, double curX) {
var high = getY(curPoint.high);
var low = getY(curPoint.low);
var open = getY(curPoint.open);
var close = getY(curPoint.close);
double r = style.candleWidth / 2;
double lineR = style.candleLineWidth / 2;
if (open >= close) {
// 实体高度>= CandleLineWidth
if (open - close < style.candleLineWidth) open = close + style.candleLineWidth;
chartPaint.color = style.colors.up;
canvas.drawRect(Rect.fromLTRB(curX - r, close, curX + r, open), chartPaint);
canvas.drawRect(Rect.fromLTRB(curX - lineR, high, curX + lineR, low), chartPaint);
} else if (close > open) {
// 实体高度>= CandleLineWidth
if (close - open < style.candleLineWidth) open = close - style.candleLineWidth;
chartPaint.color = style.colors.down;
canvas.drawRect(Rect.fromLTRB(curX - r, open, curX + r, close), chartPaint);
canvas.drawRect(Rect.fromLTRB(curX - lineR, high, curX + lineR, low), chartPaint);
}
}