echarts关系图(graph) 节点拖拽无法固定解决办法

echarts关系图(graph) 节点拖拽无法固定解决办法

方法一:echarts 绑定 mouseup事件

        //节点拖拽固定
        myChart.on('mouseup', function (params) {
          var option = myChart.getOption();
          option.series[0].data[params.dataIndex].x = params.event.offsetX;
          option.series[0].data[params.dataIndex].y = params.event.offsetY;
          option.series[0].data[params.dataIndex].fixed = true;
          myChart.setOption(option);
        });

方法二:修改echarts.js源码

找到以下部分代码,注释 this.dispatchToElement(draggingTarget, 'dragend', e.event); 这一行。

	  	_dragEnd: function (e) {
	         var draggingTarget = this._draggingTarget;
	
	         if (draggingTarget) {
	             draggingTarget.dragging = false;
	         }
	         //dispatchToElement用于控制还原节点
	         this.dispatchToElement(draggingTarget, 'dragend', e.event);
	
	         if (this._dropTarget) {
	             this.dispatchToElement(this._dropTarget, 'drop', e.event);
	         }
	
	         this._draggingTarget = null;
	         this._dropTarget = null;
	     }

你可能感兴趣的:(记录)