drawRadarText method

void drawRadarText(
  1. Canvas canvas,
  2. List<double> value,
  3. List<double> maxList,
  4. Color color,
)

Implementation

void drawRadarText(ui.Canvas canvas, List<double> value, List<double> maxList, Color color) {
  if(outLineText!=null){
    // Path mradarPath = Path();
    double step = radarMap.radius / elementLength; //每小段的长度
    // mradarPath.moveTo(0, -value[0] / (maxList[0] / value.length) * step);
    var maxWidth = 40.0;

    for (int i = 0; i < value.length; i++) {
      double mark = value[i] / (maxList[i] / value.length);
      var deg = pi / 180 * (360 / value.length * i - 90);

      final paragraphBuilder = ui.ParagraphBuilder(ui.ParagraphStyle(
          textAlign: TextAlign.center,
          fontSize: radarMap.outTextSize??10,
          fontWeight: FontWeight.normal));
      paragraphBuilder.pushStyle(ui.TextStyle(color: color , textBaseline: ui.TextBaseline.alphabetic));
      paragraphBuilder.addText(outLineText!.call(value[i],maxList[i]));
      var paragraph = paragraphBuilder.build();
      paragraph.layout(ui.ParagraphConstraints(width: maxWidth));
      var pianyix = cos(deg)*(paragraph.width/2);
      var pianyiy = sin(deg)*(paragraph.height/2);
      var of = Offset(mark * step * cos(deg) -paragraph.width/2 +pianyix , mark * step * sin(deg) - paragraph.height/2 +pianyiy);
      canvas.drawParagraph(paragraph, of);

      // mradarPath.lineTo(mark * step * cos(deg), mark * step * sin(deg));
    }
    // mradarPath.close();
    // canvas.drawPath(mradarPath, linePaint);
  }

}