drawText method

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

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),
    );
  } 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)),
      ],
    );
  }
  if (span == null) return;
  TextPainter tp = TextPainter(text: span, textDirection: TextDirection.ltr);
  tp.layout();
  tp.paint(canvas, Offset(x, chartRect.top - topPadding));
}