drawText method
Implementation
@override
void drawText(Canvas canvas, CandleEntity data, double x) {
if (isLine == true) return;
TextSpan? span;
TextSpan? span2;
TextSpan? span3;
TextSpan? span4;
if (state == MainState.MA) {
span = TextSpan(
children: _createMATextSpan(data),
);
} else if (state == MainState.BOLL) {
span = TextSpan(
children: [
if (data.up != 0)
TextSpan(
text: "BOLL:${format(data.mb)} ",
style: getTextStyle(this.chartColors.ma5Color)),
if (data.mb != 0)
TextSpan(
text: "UB:${format(data.up)} ",
style: getTextStyle(this.chartColors.ma10Color)),
if (data.dn != 0)
TextSpan(
text: "LB:${format(data.dn)} ",
style: getTextStyle(this.chartColors.ma30Color)),
],
);
span2 = TextSpan(children: []);
span3 = TextSpan(children: []);
} else if (state == MainState.MAC) {
span = TextSpan(children: [
if (data.top_box != 0)
TextSpan(
text: "TBox(5) (${format(data.top_box)}) ",
style: getTextStyle2(this.chartColors.TBoxColor)),
if (data.bottom_box != 0)
TextSpan(
text: "BBox(5) (${format(data.bottom_box)}) ",
style: getTextStyle2(this.chartColors.BBoxColor)),
if (data.moving_average != 0)
TextSpan(
text: "Pohon (${format(data.moving_average)}) ",
style: getTextStyle2(this.chartColors.ma20Color)),
if (data.mac_high != 0)
TextSpan(
text: "Orange (${format(data.mac_high)}) ",
style: getTextStyle2(this.chartColors.maHighColor)),
]);
span2 = TextSpan(
children: [],
);
span3 = TextSpan(
children: [],
);
}
if (span == null) return;
TextPainter tp = TextPainter(text: span, textDirection: TextDirection.ltr);
tp.layout();
tp.paint(canvas, Offset(x, chartRect.top - topPadding));
TextPainter tp2 =
TextPainter(text: span2, textDirection: TextDirection.ltr);
tp2.layout();
tp2.paint(canvas, Offset(x, chartRect.top - topPadding + 15));
TextPainter tp3 =
TextPainter(text: span3, textDirection: TextDirection.ltr);
tp3.layout();
tp3.paint(canvas, Offset(x, chartRect.top - topPadding + 30));
}