drawText method
Implementation
@override
void drawText(Canvas canvas, MACDEntity data, double x) {
List<TextSpan>? children;
switch (state) {
case SecondaryState.MACD:
children = [
TextSpan(text: "MACD(12,26,9) ", style: getTextStyle(style.colors.defaultText)),
if (data.macd != 0) TextSpan(text: "MACD:${format(data.macd)} ", style: getTextStyle(style.colors.macd)),
if (data.dif != 0) TextSpan(text: "DIF:${format(data.dif)} ", style: getTextStyle(style.colors.dif)),
if (data.dea != 0) TextSpan(text: "DEA:${format(data.dea)} ", style: getTextStyle(style.colors.dea))
];
break;
case SecondaryState.KDJ:
children = [
TextSpan(text: "KDJ(9,1,3) ", style: getTextStyle(style.colors.defaultText)),
if (data.macd != 0) TextSpan(text: "K:${format(data.k)} ", style: getTextStyle(style.colors.k)),
if (data.dif != 0) TextSpan(text: "D:${format(data.d)} ", style: getTextStyle(style.colors.d)),
if (data.dea != 0) TextSpan(text: "J:${format(data.j)} ", style: getTextStyle(style.colors.j))
];
break;
case SecondaryState.RSI:
children = [
TextSpan(text: "RSI(14):${format(data.rsi)} ", style: getTextStyle(style.colors.rsi))
];
break;
case SecondaryState.WR:
children = [
TextSpan(text: "WR(14):${format(data.r)} ", style: getTextStyle(style.colors.rsi))
];
break;
case SecondaryState.CCI:
children = [
TextSpan(text: "CCI(14):${format(data.cci)} ", style: getTextStyle(style.colors.rsi))
];
break;
default:
break;
}
TextPainter tp = TextPainter(text: TextSpan(children: children ?? []), textDirection: TextDirection.ltr);
tp.layout();
tp.paint(canvas, Offset(x, chartRect.top - style.padding.top));
}