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) 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(style.colors.ma5)),
        if (data.mb != 0) TextSpan(text: 'UB:${format(data.up)}    ', style: getTextStyle(style.colors.ma10)),
        if (data.dn != 0)TextSpan(text: 'LB:${format(data.dn)}    ', style: getTextStyle(style.colors.ma30)),
      ]
    );
  }

  if (span == null) return;
  TextPainter tp = TextPainter(text: span, textDirection: TextDirection.ltr);
  tp.layout();
  tp.paint(canvas, Offset(x, chartRect.top - style.padding.top + style.fontSize / 2));
}