kolMarksIcon method

dynamic kolMarksIcon(
  1. dynamic x,
  2. dynamic y,
  3. dynamic w,
  4. dynamic h,
)

Implementation

kolMarksIcon(x, y, w, h) {
  var pathData = {};
  var iconPath = [];
  var gap = 5;
  var firstGap = 2;
  if (chartData.kolMarksData.isNotEmpty) {
    var list = [];
    var i = 0,j = 0,il = chartData.kolMarksData.length;
    for(i = 0;i<il;i++){
      if(chartData.kolMarksData[i]['codeId'] == klineState.widget.propertys['codeId']){
        list = chartData.kolMarksData[i]['list'];
        gap = chartData.kolMarksData[i]['gap']??5;
        firstGap = chartData.kolMarksData[i]['firstGap']??2;
        break;
      }
    }
    if(list.isNotEmpty){
      var kolMarketsData = list;
      var kolMarketsData2 = [];
      il = kolMarketsData.length;
      j = 0;
      for (i = 0; i < il; i++) {
        var kolMarkObj = kolMarketsData[i];
        for (j = kStartI; j < kStopI; j++) {
          if (Tools.isInKline(chartData.klineData[j]['time'],
              kolMarkObj['time'], klineState.widget.propertys['interval'])) {
            kolMarkObj['kIndex'] = j - kStartI; //记录所在k线索引
            kolMarkObj['sorti'] = kolMarkObj['kIndex'] +
                (kolMarkObj['buyorsell'] == "buy" ? 1 : 2); //排序字段
            kolMarkObj['price'] = kolMarkObj['yLayout'] == "top" ? 'high' : 'low';
            kolMarkObj['codeId'] = klineState.widget.propertys['codeId'];
            kolMarketsData2.add(kolMarkObj);
            break;
          }
        }
      }
      kolMarketsData2.sort((a, b) {
        return a['sorti'].compareTo(b['sorti']);
      });
      kolMarketsDataPoint = pointKData(x, y, w, h, kolMarketsData2);
      if (kolMarketsDataPoint.isNotEmpty) {
        var preKIndex = "";
        for(i = 0;i<kolMarketsDataPoint.length;i++){
          var v = kolMarketsDataPoint[i];
          String icon = v['imageUrl'];
          String id = '${v['codeId']}${v['time']}$icon';
          dynamic iconSize = imageSize[id];
          double imagew = 0;
          if(v['width'] != null && v['width']>0){
            imagew = v['width'];
          }else if(iconSize != null){
            imagew = iconSize['w'];
          }
          double imageh = 0;
          if(v['height'] != null && v['height']>0){
            imageh = v['height'];
          }else if(iconSize != null){
            imageh = iconSize['h'];
          }
          double xoffer = 0;
          double yoffer = 0;
          double imagex = v['px'];
          double imagey = v['py'];
          if('${v['kIndex']}${v['yLayout']}' != preKIndex){
            j = 0;
            preKIndex = '${v['kIndex']}${v['yLayout']}';
          }else{
            j+=1;
          }
          if (v['yLayout'] == "top") {
            xoffer = -imagew/2;
            yoffer = -(j+1)*(imageh+(j==0?0:gap))-firstGap;//向上排 gap是每个之间的间隔 firstGap是整体偏移
          } else {
            xoffer = -imagew/2;
            yoffer = j*(imageh+gap)+firstGap;//向下排 gap是每个之间的间隔 firstGap是整体偏移
          }
          imagex += xoffer;
          imagey += yoffer;
          v['size'] = {
            'x': imagex,
            'y': imagey,
            'w': imagew,
            'h': imageh,
          };
          bool isCircle = v['isCircle']??false;
          dynamic borderColor = v['borderColor'];
          iconPath.add([
            "drawIcon",
            [
              id,
              icon,
              imagex,
              imagey,
              imagew,
              imageh,
              isCircle,
              borderColor,
            ]
          ]);
        }
      }
    }
  }
  pathData = {
    'iconPath': iconPath,
    'imageSize':imageSize,
  };
  return pathData;
}