drawText method

  1. @override
void drawText(
  1. Canvas canvas,
  2. KLineEntity data,
  3. double x
)
override

Implementation

@override
void drawText(Canvas canvas, KLineEntity data, double x) {
  List<TextSpan>? children;
  switch (state) {
    case SecondaryState.VOLATILITY:
      List<TextSpan> spans = [];
      spans.add(TextSpan(
        text: "Volatility(ATR/Close)  ",
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.volIndicator != null) {
        spans.add(TextSpan(
          text: "Vol:${format(data.volIndicator)}  ",
          style: getTextStyle(chartColors.volIndicatorColor),
        ));
      }
      TextPainter tp = TextPainter(
          text: TextSpan(children: spans), textDirection: TextDirection.ltr);
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.ENVELOPES:
      List<TextSpan> spans = [];
      spans.add(TextSpan(
        text: "Envelopes(20,2%)  ",
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.envMid != null) {
        spans.add(TextSpan(
          text: "MID:${format(data.envMid)}  ",
          style: getTextStyle(chartColors.envMidColor),
        ));
      }
      if (data.envUp != null) {
        spans.add(TextSpan(
          text: "UP:${format(data.envUp)}  ",
          style: getTextStyle(chartColors.envUpColor),
        ));
      }
      if (data.envDn != null) {
        spans.add(TextSpan(
          text: "DN:${format(data.envDn)}  ",
          style: getTextStyle(chartColors.envDnColor),
        ));
      }
      TextPainter tp = TextPainter(
          text: TextSpan(children: spans), textDirection: TextDirection.ltr);
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.SUPER_TREND:
      List<TextSpan> spans = [];
      spans.add(TextSpan(
        text: "SuperTrend  ",
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.superTrend != null) {
        final Color trendColor = (data.superTrendDirection ?? 1.0) >= 0
            ? chartColors.superTrendUpColor
            : chartColors.superTrendDownColor;
        spans.add(TextSpan(
          text: "ST:${format(data.superTrend)}  ",
          style: getTextStyle(trendColor),
        ));
      }
      if (data.superTrendUpper != null) {
        spans.add(TextSpan(
          text: "UP:${format(data.superTrendUpper)}  ",
          style: getTextStyle(chartColors.superTrendUpperColor),
        ));
      }
      if (data.superTrendLower != null) {
        spans.add(TextSpan(
          text: "DN:${format(data.superTrendLower)}  ",
          style: getTextStyle(chartColors.superTrendLowerColor),
        ));
      }
      TextPainter tp = TextPainter(
          text: TextSpan(children: spans), textDirection: TextDirection.ltr);
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.STC:
      List<TextSpan> stcSpans = [];
      stcSpans.add(TextSpan(
        text: "STC  ",
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.stc != null) {
        stcSpans.add(TextSpan(
          text: "${format(data.stc)}  ",
          style: getTextStyle(chartColors.stcColor),
        ));
      }
      TextPainter tpStc = TextPainter(
          text: TextSpan(children: stcSpans),
          textDirection: TextDirection.ltr);
      tpStc.layout();
      tpStc.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.QQE:
      List<TextSpan> qqeSpans = [];
      qqeSpans.add(TextSpan(
        text: "QQE  ",
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.qqe != null) {
        qqeSpans.add(TextSpan(
          text: "Main:${format(data.qqe)}  ",
          style: getTextStyle(chartColors.qqeColor),
        ));
      }
      if (data.qqeSignal != null) {
        qqeSpans.add(TextSpan(
          text: "Sig:${format(data.qqeSignal)}  ",
          style: getTextStyle(chartColors.qqeSignalColor),
        ));
      }
      TextPainter tpQqe = TextPainter(
          text: TextSpan(children: qqeSpans),
          textDirection: TextDirection.ltr);
      tpQqe.layout();
      tpQqe.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.WAVE_TREND:
      List<TextSpan> wtSpans = [];
      wtSpans.add(TextSpan(
        text: "WaveTrend  ",
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.waveTrend1 != null) {
        wtSpans.add(TextSpan(
          text: "WT1:${format(data.waveTrend1)}  ",
          style: getTextStyle(chartColors.waveTrend1Color),
        ));
      }
      if (data.waveTrend2 != null) {
        wtSpans.add(TextSpan(
          text: "WT2:${format(data.waveTrend2)}  ",
          style: getTextStyle(chartColors.waveTrend2Color),
        ));
      }
      TextPainter tpWt = TextPainter(
          text: TextSpan(children: wtSpans),
          textDirection: TextDirection.ltr);
      tpWt.layout();
      tpWt.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.CMO:
      List<TextSpan> cmoSpans = [];
      cmoSpans.add(TextSpan(
        text: "CMO  ",
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.cmo != null) {
        cmoSpans.add(TextSpan(
          text: "${format(data.cmo)}  ",
          style: getTextStyle(chartColors.cmoColor),
        ));
      }
      TextPainter tpCmo = TextPainter(
          text: TextSpan(children: cmoSpans),
          textDirection: TextDirection.ltr);
      tpCmo.layout();
      tpCmo.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.EOM:
      List<TextSpan> eomSpans = [];
      eomSpans.add(TextSpan(
        text: "EOM  ",
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.eom != null) {
        eomSpans.add(TextSpan(
          text: "${format(data.eom)}  ",
          style: getTextStyle(chartColors.eomColor),
        ));
      }
      TextPainter tpEom = TextPainter(
          text: TextSpan(children: eomSpans),
          textDirection: TextDirection.ltr);
      tpEom.layout();
      tpEom.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.PVI_NVI:
      List<TextSpan> pviSpans = [];
      pviSpans.add(TextSpan(
        text: "PVI/NVI  ",
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.pvi != null) {
        pviSpans.add(TextSpan(
          text: "P:${format(data.pvi)}  ",
          style: getTextStyle(chartColors.pviColor),
        ));
      }
      if (data.nvi != null) {
        pviSpans.add(TextSpan(
          text: "N:${format(data.nvi)}  ",
          style: getTextStyle(chartColors.nviColor),
        ));
      }
      TextPainter tpPvi = TextPainter(
          text: TextSpan(children: pviSpans),
          textDirection: TextDirection.ltr);
      tpPvi.layout();
      tpPvi.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.MFI:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "MFI(14)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.mfi != null) {
        spans.add(TextSpan(
          text: "MFI:${format(data.mfi)}  ",
          style: getTextStyle(chartColors.mfiColor),
        ));
      }
      TextPainter tp = TextPainter(
          text: TextSpan(children: spans), textDirection: TextDirection.ltr);
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.MOMENTUM:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "Momentum(10)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.momentum != null) {
        spans.add(TextSpan(
          text: "MOM:${format(data.momentum)}  ",
          style: getTextStyle(chartColors.momentumColor),
        ));
      }
      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.DEMARKER:
      List<TextSpan> spans = [];
      spans.add(TextSpan(
        text: "DeM(14)  ",
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.dem != null) {
        // 若是 [0,1], 也可 *100 => 0~100
        spans.add(TextSpan(
          text: "DeM:${format(data.dem)}  ",
          style: getTextStyle(chartColors.demColor),
        ));
      }

      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.WPR:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "WPR(14)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.wpr != null) {
        spans.add(TextSpan(
          text: "%R:${format(data.wpr)}  ",
          style: getTextStyle(chartColors.wprColor),
        ));
      }
      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.STOCHASTIC:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "Stoch(14,3)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.stochK != null) {
        spans.add(TextSpan(
          text: "K:${format(data.stochK)}  ",
          style: getTextStyle(chartColors.stochKColor),
        ));
      }
      if (data.stochD != null) {
        spans.add(TextSpan(
          text: "D:${format(data.stochD)}  ",
          style: getTextStyle(chartColors.stochDColor),
        ));
      }

      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.STDDEV:
      List<TextSpan> spans = [];
      spans.add(TextSpan(
        text: "StdDev(14)  ",
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.stdDev != null) {
        spans.add(TextSpan(
          text: "SD:${format(data.stdDev)}  ",
          style: getTextStyle(chartColors.stdDevColor),
        ));
      }

      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.ADX:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "ADX(14)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.adx != null) {
        spans.add(
          TextSpan(
            text: "ADX:${format(data.adx)}  ",
            style: getTextStyle(chartColors.adxColor),
          ),
        );
      }
      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.VIX:
      List<TextSpan> spans = [];
      spans.add(TextSpan(
        text: "VIX(14)  ", // 如果你算14日近似
        style: getTextStyle(chartColors.defaultTextColor),
      ));
      if (data.vix != null) {
        spans.add(TextSpan(
          text: "VIX:${format(data.vix)}  ",
          style: getTextStyle(chartColors.vixColor),
        ));
      }

      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.ADL:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "A/D Line  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.adl != null) {
        spans.add(TextSpan(
          text: "ADL:${format(data.adl)}  ",
          style: getTextStyle(chartColors.adlColor),
        ));
      }

      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.OBV:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "OBV(Vol), EMA(10)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.obv != null) {
        spans.add(TextSpan(
          text: "OBV:${format(data.obv)}  ",
          style: getTextStyle(chartColors.obvColor),
        ));
      }
      if (data.obvEma != null) {
        spans.add(TextSpan(
          text: "OBV-EMA:${format(data.obvEma)}  ",
          style: getTextStyle(chartColors.obvEmaColor),
        ));
      }

      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.VWAP:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "VWAP  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.vwap != null) {
        spans.add(
          TextSpan(
            text: "VWAP:${format(data.vwap)}  ",
            style: getTextStyle(chartColors.vwapColor),
          ),
        );
      }
      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.HV:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "HV(14)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.hv != null) {
        spans.add(
          TextSpan(
            text: "HV:${format(data.hv)}  ", // 假设data.hv=25.3 -> "25.30"
            style: getTextStyle(chartColors.hvColor),
          ),
        );
      }

      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.ATR:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "ATR(14)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.atr != null) {
        spans.add(
          TextSpan(
            text: "ATR:${format(data.atr)}  ",
            style: getTextStyle(chartColors.atrColor),
          ),
        );
      }
      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.VORTEX:
      List<TextSpan> children = [];
      children.add(
        TextSpan(
          text: "Vortex(14)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.viPlus != null) {
        children.add(TextSpan(
          text: "+VI:${format(data.viPlus)}  ",
          style: getTextStyle(chartColors.vortexPlusColor),
        ));
      }
      if (data.viMinus != null) {
        children.add(TextSpan(
          text: "-VI:${format(data.viMinus)}  ",
          style: getTextStyle(chartColors.vortexMinusColor),
        ));
      }

      TextPainter tp = TextPainter(
        text: TextSpan(children: children),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.AROON:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "Aroon(14)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );

      if (data.aroonUp != null) {
        spans.add(TextSpan(
          text: "Up:${format(data.aroonUp)}  ",
          style: getTextStyle(chartColors.aroonUpColor),
        ));
      }
      if (data.aroonDown != null) {
        spans.add(TextSpan(
          text: "Down:${format(data.aroonDown)}  ",
          style: getTextStyle(chartColors.aroonDownColor),
        ));
      }
      if (data.aroonOsc != null) {
        spans.add(TextSpan(
          text: "Osc:${format(data.aroonOsc)}  ",
          style: getTextStyle(chartColors.aroonOscColor),
        ));
      }

      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.SAR:
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "SAR(0.02,0.2)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );
      if (data.psar != null) {
        spans.add(
          TextSpan(
            text: "PSAR:${format(data.psar)}  ",
            style: getTextStyle(chartColors.sarColor),
          ),
        );
      }

      // 组装
      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.ICHIMOKU:
      // 组合5条线的字段到 children
      List<TextSpan> spans = [];
      spans.add(
        TextSpan(
          text: "Ichimoku(9,26,52)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
      );

      if (data.ichimokuTenkan != null) {
        spans.add(TextSpan(
            text: "Tenkan:${format(data.ichimokuTenkan)}  ",
            style: getTextStyle(chartColors.ichimokuTenkanColor)));
      }
      if (data.ichimokuKijun != null) {
        spans.add(TextSpan(
            text: "Kijun:${format(data.ichimokuKijun)}  ",
            style: getTextStyle(chartColors.ichimokuKijunColor)));
      }
      if (data.ichimokuSpanA != null) {
        spans.add(TextSpan(
            text: "SpanA:${format(data.ichimokuSpanA)}  ",
            style: getTextStyle(chartColors.ichimokuSpanAColor)));
      }
      if (data.ichimokuSpanB != null) {
        spans.add(TextSpan(
            text: "SpanB:${format(data.ichimokuSpanB)}  ",
            style: getTextStyle(chartColors.ichimokuSpanBColor)));
      }
      if (data.ichimokuChikou != null) {
        spans.add(TextSpan(
            text: "Chikou:${format(data.ichimokuChikou)}  ",
            style: getTextStyle(chartColors.ichimokuChikouColor)));
      }

      // 将span列表转成TextSpan
      TextPainter tp = TextPainter(
        text: TextSpan(children: spans),
        textDirection: TextDirection.ltr,
      );
      tp.layout();
      // 在 secondaryRect 顶部一点的位置画文字
      tp.paint(canvas, Offset(x, chartRect.top - topPadding));
      break;

    case SecondaryState.TSI:
      children = [
        TextSpan(
            text: "TSI(25,13,9)  ",
            style: getTextStyle(chartColors.defaultTextColor)),
        if (data.tsi != null)
          TextSpan(
              text: "TSI:${format(data.tsi)}  ",
              style: getTextStyle(chartColors.tsiColor)),
        if (data.tsiSignal != null)
          TextSpan(
              text: "SIGNAL:${format(data.tsiSignal)}  ",
              style: getTextStyle(chartColors.tsiSignalColor)),
      ];
      break;

    case SecondaryState.PPO:
      children = [
        TextSpan(
          text: "PPO(12,26,9)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
        if (data.ppo != null)
          TextSpan(
            text: "PPO:${format(data.ppo)}  ",
            style: getTextStyle(chartColors.ppoColor),
          ),
        if (data.ppoSignal != null)
          TextSpan(
            text: "SIGNAL:${format(data.ppoSignal)}  ",
            style: getTextStyle(chartColors.ppoSignalColor),
          ),
      ];
      break;
    case SecondaryState.TRIX:
      children = [
        TextSpan(
          text: "TRIX(12,9)  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
        if (data.trix != null)
          TextSpan(
            text: "TRIX:${format(data.trix)}  ",
            style: getTextStyle(chartColors.trixColor),
          ),
        if (data.trixSignal != null)
          TextSpan(
            text: "SIGNAL:${format(data.trixSignal)}  ",
            style: getTextStyle(chartColors.trixSignalColor),
          ),
      ];
      break;
    case SecondaryState.DMI:
      children = [
        TextSpan(
          text: "DMI(14):  ",
          style: getTextStyle(chartColors.defaultTextColor),
        ),
        if (data.pdi != null)
          TextSpan(
            text: "PDI:${format(data.pdi)}  ",
            style: getTextStyle(chartColors.dmiPdiColor),
          ),
        if (data.mdi != null)
          TextSpan(
            text: "MDI:${format(data.mdi)}  ",
            style: getTextStyle(chartColors.dmiMdiColor),
          ),
        if (data.adx != null)
          TextSpan(
            text: "ADX:${format(data.adx)}  ",
            style: getTextStyle(chartColors.dmiAdxColor),
          ),
        if (data.adxr != null)
          TextSpan(
            text: "ADXR:${format(data.adxr)}  ",
            style: getTextStyle(chartColors.dmiAdxrColor),
          ),
      ];
      break;
    case SecondaryState.MACD:
      children = [
        TextSpan(
            text: "MACD(12,26,9)    ",
            style: getTextStyle(this.chartColors.defaultTextColor)),
        if (data.macd != 0)
          TextSpan(
              text: "MACD:${format(data.macd)}    ",
              style: getTextStyle(this.chartColors.macdColor)),
        if (data.dif != 0)
          TextSpan(
              text: "DIF:${format(data.dif)}    ",
              style: getTextStyle(this.chartColors.difColor)),
        if (data.dea != 0)
          TextSpan(
              text: "DEA:${format(data.dea)}    ",
              style: getTextStyle(this.chartColors.deaColor)),
        if (data.osma != 0)
          TextSpan(
            text: "OsMA:${format(data.osma)}  ",
            style: getTextStyle(chartColors.osmaColor),
          )
      ];
      break;
    case SecondaryState.KDJ:
      children = [
        TextSpan(
            text: "KDJ(9,1,3)    ",
            style: getTextStyle(this.chartColors.defaultTextColor)),
        if (data.macd != 0)
          TextSpan(
              text: "K:${format(data.k)}    ",
              style: getTextStyle(this.chartColors.kColor)),
        if (data.dif != 0)
          TextSpan(
              text: "D:${format(data.d)}    ",
              style: getTextStyle(this.chartColors.dColor)),
        if (data.dea != 0)
          TextSpan(
              text: "J:${format(data.j)}    ",
              style: getTextStyle(this.chartColors.jColor)),
      ];
      break;
    case SecondaryState.RSI:
      children = [
        TextSpan(
            text: "RSI(14):${format(data.rsi)}    ",
            style: getTextStyle(this.chartColors.rsiColor)),
      ];
      break;
    case SecondaryState.WR:
      children = [
        TextSpan(
            text: "WR(14):${format(data.r)}    ",
            style: getTextStyle(this.chartColors.rsiColor)),
      ];
      break;
    case SecondaryState.CCI:
      children = [
        TextSpan(
            text: "CCI(14):${format(data.cci)}    ",
            style: getTextStyle(this.chartColors.rsiColor)),
      ];
      break;
    case SecondaryState.CMF:
      children = [
        TextSpan(
            text: "CMF:${format(data.cmf)}  ",
            style: getTextStyle(chartColors.cmfColor)),
      ];
      break;
    case SecondaryState.CHAIKIN_OSC:
      children = [
        TextSpan(
            text: "Chaikin Osc:${format(data.chaikinOscillator)}  ",
            style: getTextStyle(chartColors.chaikinOscColor)),
      ];
      break;
    case SecondaryState.KLINGER:
      children = [
        TextSpan(
            text: "KVO:${format(data.kvo)}  ",
            style: getTextStyle(chartColors.klingerColor)),
        TextSpan(
            text: "Sig:${format(data.kvoSignal)}  ",
            style: getTextStyle(chartColors.klingerSignalColor)),
      ];
      break;
    case SecondaryState.VPT:
      children = [
        TextSpan(
            text: "VPT:${format(data.vpt)}  ",
            style: getTextStyle(chartColors.vptColor)),
      ];
      break;
    case SecondaryState.FORCE:
      children = [
        TextSpan(
            text: "Force:${format(data.forceIndex)}  ",
            style: getTextStyle(chartColors.forceIndexColor)),
      ];
      break;
    case SecondaryState.ROC:
      children = [
        TextSpan(
            text: "ROC:${format(data.roc)}  ",
            style: getTextStyle(chartColors.rocColor)),
        TextSpan(
            text: "Sig:${format(data.rocSignal)}  ",
            style: getTextStyle(chartColors.rocSignalColor)),
      ];
      break;
    case SecondaryState.ULTIMATE:
      children = [
        TextSpan(
            text: "Ultimate:${format(data.ultimateOsc)}  ",
            style: getTextStyle(chartColors.ultimateOscColor)),
      ];
      break;
    case SecondaryState.CONNORS_RSI:
      children = [
        TextSpan(
            text: "ConnorsRSI:${format(data.connorsRsi)}  ",
            style: getTextStyle(chartColors.connorsRsiColor)),
      ];
      break;
    case SecondaryState.STOCH_RSI:
      children = [
        TextSpan(
            text: "StochRSI %K:${format(data.stochRsiK)}  ",
            style: getTextStyle(chartColors.stochRsiKColor)),
        TextSpan(
            text: "%D:${format(data.stochRsiD)}  ",
            style: getTextStyle(chartColors.stochRsiDColor)),
      ];
      break;
    case SecondaryState.RVI:
      children = [
        TextSpan(
            text: "RVI:${format(data.rvi)}  ",
            style: getTextStyle(chartColors.rviColor)),
        TextSpan(
            text: "Sig:${format(data.rviSignal)}  ",
            style: getTextStyle(chartColors.rviSignalColor)),
      ];
      break;
    case SecondaryState.DPO:
      children = [
        TextSpan(
            text: "DPO:${format(data.dpo)}  ",
            style: getTextStyle(chartColors.dpoColor)),
      ];
      break;
    case SecondaryState.KAMA:
      children = [
        TextSpan(
            text: "KAMA:${format(data.kama)}  ",
            style: getTextStyle(chartColors.kamaColor)),
      ];
      break;
    case SecondaryState.HMA:
      children = [
        TextSpan(
            text: "HMA:${format(data.hma)}  ",
            style: getTextStyle(chartColors.hmaColor)),
      ];
      break;
    case SecondaryState.KELTNER:
      children = [
        TextSpan(
            text: "Keltner Mid:${format(data.keltnerMiddle)}  ",
            style: getTextStyle(chartColors.keltnerMidColor)),
        TextSpan(
            text: "Up:${format(data.keltnerUpper)}  ",
            style: getTextStyle(chartColors.keltnerUpColor)),
        TextSpan(
            text: "Dn:${format(data.keltnerLower)}  ",
            style: getTextStyle(chartColors.keltnerDnColor)),
      ];
      break;
    case SecondaryState.DONCHIAN:
      children = [
        TextSpan(
            text: "Donchian Mid:${format(data.donchianMiddle)}  ",
            style: getTextStyle(chartColors.donchianMidColor)),
        TextSpan(
            text: "Up:${format(data.donchianUpper)}  ",
            style: getTextStyle(chartColors.donchianUpColor)),
        TextSpan(
            text: "Dn:${format(data.donchianLower)}  ",
            style: getTextStyle(chartColors.donchianDnColor)),
      ];
      break;
    case SecondaryState.BOLL_BANDWIDTH:
      children = [
        TextSpan(
            text: "Boll BW:${format(data.bollBandwidth)}  ",
            style: getTextStyle(chartColors.bollBandwidthColor)),
      ];
      break;
    case SecondaryState.CHAIKIN_VOLATILITY:
      children = [
        TextSpan(
            text: "Chaikin Vol:${format(data.chaikinVolatility)}  ",
            style: getTextStyle(chartColors.chaikinVolatilityColor)),
      ];
      break;
    case SecondaryState.HV_PERCENTILE:
      children = [
        TextSpan(
            text: "HV %:${format(data.hvPercentile)}  ",
            style: getTextStyle(chartColors.hvPercentileColor)),
      ];
      break;
    case SecondaryState.ATR_PERCENTILE:
      children = [
        TextSpan(
            text: "ATR %:${format(data.atrPercentile)}  ",
            style: getTextStyle(chartColors.atrPercentileColor)),
      ];
      break;
    case SecondaryState.ELDER_RAY:
      children = [
        TextSpan(
            text: "Bull:${format(data.elderBull)}  ",
            style: getTextStyle(chartColors.elderBullColor)),
        TextSpan(
            text: "Bear:${format(data.elderBear)}  ",
            style: getTextStyle(chartColors.elderBearColor)),
      ];
      break;
    case SecondaryState.ICHIMOKU_SPAN:
      children = [
        TextSpan(
            text: "SpanΔ:${format(data.ichimokuSpanDiff)}  ",
            style: getTextStyle(chartColors.ichimokuSpanDiffColor)),
      ];
      break;
    case SecondaryState.PIVOT:
      children = [
        TextSpan(
            text: "Pivot:${format(data.pivot)}  ",
            style: getTextStyle(chartColors.pivotColor)),
        TextSpan(
            text: "R1:${format(data.pivotR1)}  ",
            style: getTextStyle(chartColors.pivotResistanceColor)),
        TextSpan(
            text: "S1:${format(data.pivotS1)}  ",
            style: getTextStyle(chartColors.pivotSupportColor)),
      ];
      break;
    case SecondaryState.GANN_FAN:
      children = [
        TextSpan(
            text: "Gann1x1:${format(data.gann1x1)}  ",
            style: getTextStyle(chartColors.gann1x1Color)),
        TextSpan(
            text: "1x2:${format(data.gann1x2)}  ",
            style: getTextStyle(chartColors.gann1x2Color)),
        TextSpan(
            text: "2x1:${format(data.gann2x1)}  ",
            style: getTextStyle(chartColors.gann2x1Color)),
      ];
      break;
    default:
      break;
  }
  TextPainter tp = TextPainter(
      text: TextSpan(children: children ?? []),
      textDirection: TextDirection.ltr);
  tp.layout();
  tp.paint(canvas, Offset(x, chartRect.top - topPadding));
}