From ec38a9175d0e77c9b74dcbd19b4313cfd31ad822 Mon Sep 17 00:00:00 2001 From: lang Date: Wed, 4 May 2016 21:44:20 +0800 Subject: [PATCH] Graph using layout except force can't set draggable: true --- src/chart/graph/GraphView.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/chart/graph/GraphView.js b/src/chart/graph/GraphView.js index 85c36b223..563998050 100644 --- a/src/chart/graph/GraphView.js +++ b/src/chart/graph/GraphView.js @@ -45,7 +45,6 @@ define(function (require) { symbolDraw.updateData(data); var edgeData = data.graph.edgeData; - var rawOption = seriesModel.option; var formatModel = modelUtil.createDataFormatModel(seriesModel, edgeData); formatModel.formatTooltip = function (dataIndex) { var params = this.getDataParams(dataIndex); @@ -99,22 +98,26 @@ define(function (require) { // Update draggable data.eachItemGraphicEl(function (el, idx) { var draggable = data.getItemModel(idx).get('draggable'); - if (draggable && forceLayout) { + if (draggable) { el.on('drag', function () { - forceLayout.warmUp(); - !this._layouting - && this._startForceLayoutIteration(forceLayout, layoutAnimation); - forceLayout.setFixed(idx); - // Write position back to layout - data.setItemLayout(idx, el.position); + if (forceLayout) { + forceLayout.warmUp(); + !this._layouting + && this._startForceLayoutIteration(forceLayout, layoutAnimation); + forceLayout.setFixed(idx); + // Write position back to layout + data.setItemLayout(idx, el.position); + } }, this).on('dragend', function () { - forceLayout.setUnfixed(idx); + if (forceLayout) { + forceLayout.setUnfixed(idx); + } }, this); } else { el.off('drag'); } - el.setDraggable(draggable); + el.setDraggable(draggable && forceLayout); }, this); this._firstRender = false; -- GitLab