zl2fxy commented on issue #6811:
URL: https://github.com/apache/echarts/issues/6811#issuecomment-2580119241

   function handlerEdges(uniqueArray) {
       var groupBy = {};
       let groupByList = Array.from(new Set(uniqueArray.map(x => 
x.qweGroupBy)));
   
       groupByList.forEach(item => {
           let key = item;
           if (!groupBy[key]) {
               groupBy[key] = [];
           };
           //找自身和对向数据
           let filters = uniqueArray.filter(x => (x.qweGroupBy == key || 
x.qweGroupByFaXiang == key) && x.WC == false);
           groupBy[key] = groupBy[key].concat(filters);
           //找完了标记,下次不能被使用
           filters.forEach(filterItem => { 
               uniqueArray.find(x => x.qweUuid == filterItem.qweUuid).WC = true;
           });
       });
       
       let shuju = [];
   
       //开始算曲率
       for (const [key, value] of Object.entries(groupBy)) {
           let length = value.length;
           //判断是否有对向数据
           let hasDuiXiang = Array.from(new Set(value.map(x => 
x.qweGroupBy))).length > 1;
           
           if (hasDuiXiang) {
               var zhengXiangs = value.filter(x => x.qweGroupBy == key);
               var fanXiangs = value.filter(x => x.qweGroupByFaXiang == key);
               //加成系数,如果两边数量相等, 就对称,不相等就从最中间线开始
               var jiachengXiShu = zhengXiangs.length == fanXiangs.length ? 1 : 
0;
               zhengXiangs.forEach((item, index) => {
                   item.curveness = (index + jiachengXiShu) * 0.1;
                   item.lineStyle = {
                       width: 1,
                       color: 'source',
                       curveness: item.curveness
                   };
                   shuju.push(item);
               });
               fanXiangs.forEach((item, index) => {
                   item.curveness = (index + 1) * 0.1;
                   item.lineStyle = {
                       width: 1,
                       color: 'source',
                       curveness: item.curveness
                   };
                   shuju.push(item);
               });
   
           }
           else {
               // 求商
               let quotient = Math.floor(length / 2);
               let remainder = length % 2;
               if (remainder == 0) {
                   value.forEach((item, index) => {
                       if (index < quotient) {
                           item.curveness = (index + 1) * 0.1;
                       }
                       else {
                           item.curveness = -(((index - quotient) + 1) * 0.1);
                       }
                       item.lineStyle = {
                           width: 1,
                           color: 'source',
                           curveness: item.curveness
                       };
                       if (item.to == item.form) {
                           item.lineStyle.curveness = 0.8
                       }
                       shuju.push(item);
                   })
               }
               else {
                   value.forEach((item, index) => {
                       if (index < quotient) {
                           item.curveness = (index + 1) * 0.1;
                       }
                       else if (index == quotient) {
                           item.curveness = 0;
                       }
                       else {
                           item.curveness = -(((index - quotient) + 1) * 0.1);
                       }
                       item.lineStyle = {
                           width: 1,
                           color: 'source',
                           curveness: item.curveness
                       };
                       if (item.to == item.form) {
                           item.lineStyle.curveness = 0.8
                       }
                       shuju.push(item);
                   })
               }
           }
           
       }
       return shuju;
   }


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to