drawText method
Implementation
@override
void drawText(Canvas canvas, CandleEntity data, double x) {
if (isLine == true) return;
TextSpan? span;
if (state == MainState.mA) {
// span = TextSpan(
// children: _createMATextSpan(data),
// );
String value = format((data.maValueList ?? [0])[0]);
span = TextSpan(
children: [
TextSpan(
children: _createMATextSpan(data),
),
if (chartStyle.isShowEma && value.length <= 13)
//EMA
TextSpan(text: '\n'),
if (chartStyle.isShowEma)
TextSpan(
children: _createEMATextSpan(data),
),
],
);
} else if (state == MainState.bOLL) {
span = TextSpan(
children: [
if (data.up != 0)
TextSpan(
text: "BOLL:${format(data.mb)} ",
style: getTextStyle(chartColors.ma5Color)),
if (data.mb != 0)
TextSpan(
text: "UB:${format(data.up)} ",
style: getTextStyle(chartColors.ma10Color)),
if (data.dn != 0)
TextSpan(
text: "LB:${format(data.dn)} ",
style: getTextStyle(chartColors.ma30Color)),
],
);
}
if (span == null) {
return;
}
TextPainter tp = TextPainter(text: span, textDirection: TextDirection.ltr);
tp.layout();
if (chartStyle.isShowStrategyTypeTop) {
tp.paint(canvas, Offset(x, chartRect.top - topPadding));
}
}