drawBuy method
Implementation
void drawBuy(Canvas canvas) {
mBuyPointWidth =
(mDrawWidth / (mBuyData!.length - 1 == 0 ? 1 : mBuyData!.length - 1));
mBuyPath!.reset();
double x;
double y;
for (int i = 0; i < mBuyData!.length; i++) {
if (i == 0) {
mBuyPath!.moveTo(0, getY(mBuyData![0].vol));
}
x = mBuyPointWidth! * i;
y = getY(mBuyData![i].vol);
if (i >= 1) {
canvas.drawLine(
Offset(mBuyPointWidth! * (i - 1), getY(mBuyData![i - 1].vol)),
Offset(x, y),
mBuyLinePaint!);
}
if (i != mBuyData!.length - 1) {
mBuyPath!.quadraticBezierTo(
x, y, mBuyPointWidth! * (i + 1), getY(mBuyData![i + 1].vol));
} else {
if (i == 0) {
mBuyPath!.lineTo(mDrawWidth, y);
mBuyPath!.lineTo(mDrawWidth, mDrawHeight);
mBuyPath!.lineTo(0, mDrawHeight);
} else {
mBuyPath!.quadraticBezierTo(x, y, x, mDrawHeight);
mBuyPath!.quadraticBezierTo(x, mDrawHeight, 0, mDrawHeight);
}
mBuyPath!.close();
}
}
canvas.drawPath(mBuyPath!, mBuyPathPaint!);
}