You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/03/30 07:42:52 UTC

[GitHub] [echarts] xuqingxi opened a new issue #14555: 关系图拖动改变节点位置,其它节点位置不要变化

xuqingxi opened a new issue #14555:
URL: https://github.com/apache/echarts/issues/14555


   ### What problem does this feature solve?
   我想用echarts关系图实现流程图设计,希望其它节点不要动,而且我想知道鼠标位置和关系图节点坐标怎么对应的,初始化的position对不上,下面这个是官网simple Graph实现的样例
    
   ```
   let data = [{
                   name: '节点1',
                   x: 100,
                   y: 100
               }, {
                   name: '节点2',
                   x: 800,
                   y: 300
               },
               {
                   name: '节点3',
                   x: 500,
                   y: 100
               }];
   option = {
       title: {
           text: 'Graph 简单示例'
       },
       tooltip: {},
       animation:false,
       
       series: [
           {
               type: 'graph',
               layout: 'none',
               symbolSize: 20,
               roam: false,
            
               edgeSymbol: ['circle', 'arrow'],
               edgeSymbolSize: [4, 10],
               edgeLabel: {
                   fontSize: 20
               },
               data: data,
               // links: [],
               links: [{
                   source: 0,
                   target: 1,
                   // symbolSize: [5, 20],
                   // label: {
                   //     show: true
                   // }
               }, {
                   source: '节点2',
                   target: '节点1',
                   label: {
                       show: true
                   }
               }, {
                   source: '节点1',
                   target: '节点3'
               }, {
                   source: '节点2',
                   target: '节点3'
               }, {
                   source: '节点2',
                   target: '节点4'
               }, {
                   source: '节点1',
                   target: '节点4'
               }],
               lineStyle: {
                   opacity: 0.9,
                   width: 1,
                   curveness: 0
               }
           }
       ]
   };
   setTimeout(function () {
       // Add shadow circles (which is not visible) to enable drag.
       myChart.setOption({
           graphic: data.map(function (item, dataIndex) {
               return {
                   type: 'circle',
                   position:  myChart.convertFromPixel({seriesIndex: 0},[item.x,item.y]),
                   shape: {
                       cx: 0,
                       cy: 0,
                       r: 10
                   },
                   invisible: false,
                   draggable: true,
                   ondrag: function (dx, dy) {
                      
                      let index = data.findIndex((dataItem)=>{
                          return dataItem.name == item.name
                      })
                      let convertPos = myChart.convertFromPixel({seriesIndex: 0},[this.x,this.y])
                      data[index].x = convertPos[0];
                      data[index].y = convertPos[1];
                      console.log(data[index])
                      myChart.setOption(option)
                   },
                   onmousemove: function () {
                       
                   },
                   onmouseout: function () {
                      
                   },
                   z: 100
               };
           })
       });
   }, 0);
   ```
   
   ### What does the proposed API look like?
   和原来一样
   
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   <!-- This issue is in English. DO NOT REMOVE -->


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] echarts-bot[bot] commented on issue #14555: 关系图拖动改变节点位置,其它节点位置不要变化

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on issue #14555:
URL: https://github.com/apache/echarts/issues/14555#issuecomment-813879550


   This issue is labeled with `difficulty: easy`.
   @xuqingxi Would you like to debug it by yourself? This is a quicker way to get your problem fixed. Or you may wait for the community to fix.
   
   Please have a look at [How to debug ECharts](https://github.com/apache/echarts/blob/master/CONTRIBUTING.md#how-to-debug-echarts) if you'd like to give a try. 🤓


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] echarts-bot[bot] commented on issue #14555: 关系图拖动改变节点位置,其它节点位置不要变化

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on issue #14555:
URL: https://github.com/apache/echarts/issues/14555#issuecomment-809993701






-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org