You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by de...@apache.org on 2018/08/09 13:30:15 UTC

[incubator-echarts] branch master updated: fix(sankey): fix the flashing of the screen when dragging the node

This is an automated email from the ASF dual-hosted git repository.

deqingli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/master by this push:
     new 082c54d  fix(sankey): fix the flashing of the screen when dragging the node
     new 6d43d3a  Merge branch 'master' of https://github.com/apache/incubator-echarts
082c54d is described below

commit 082c54d0376eaf11dbfdde7e262fd165a6afb63d
Author: deqingli <an...@gmail.com>
AuthorDate: Thu Aug 9 21:28:21 2018 +0800

    fix(sankey): fix the flashing of the screen when dragging the node
---
 src/chart/sankey/SankeyView.js | 62 ++++++++++++++++++++++++++----------------
 1 file changed, 38 insertions(+), 24 deletions(-)

diff --git a/src/chart/sankey/SankeyView.js b/src/chart/sankey/SankeyView.js
index 3bfcf75..6807f63 100644
--- a/src/chart/sankey/SankeyView.js
+++ b/src/chart/sankey/SankeyView.js
@@ -100,7 +100,14 @@ export default echarts.extendChartView({
      */
     _model: null,
 
+    /**
+     * @private
+     * @type {boolean}
+     */
+    _focusAdjacencyDisabled: false,
+
     render: function (seriesModel, ecModel, api) {
+        var sankeyView = this;
         var graph = seriesModel.getGraph();
         var group = this.group;
         var layoutInfo = seriesModel.layoutInfo;
@@ -111,6 +118,7 @@ export default echarts.extendChartView({
         
         var nodeData = seriesModel.getData();
         var edgeData = seriesModel.getData('edge');
+        var orient = seriesModel.get('orient');
 
         this._model = seriesModel;
 
@@ -127,7 +135,7 @@ export default echarts.extendChartView({
             var lineStyleModel = edge.getModel('lineStyle');
             var curvature = lineStyleModel.get('curveness');
             var n1Layout = edge.node1.getLayout();
-            var node1Model =edge.node1.getModel();
+            var node1Model = edge.node1.getModel();
             var dragX1 = node1Model.get('localX');
             var dragY1 = node1Model.get('localY');
             var n2Layout = edge.node2.getLayout();
@@ -176,7 +184,7 @@ export default echarts.extendChartView({
             edgeData.setItemGraphicEl(edge.dataIndex, curve);
         });
 
-        // generate a rect for each node
+        // Generate a rect for each node
         graph.eachNode(function (node) {
             var layout = node.getLayout();
             var itemModel = node.getModel();
@@ -220,9 +228,9 @@ export default echarts.extendChartView({
        
         nodeData.eachItemGraphicEl(function (el, dataIndex) {
             var itemModel = nodeData.getItemModel(dataIndex);
-            // var draggable = seriesModel.get('draggable');
             if (itemModel.get('draggable')) {
                 el.drift = function (dx, dy) {
+                    sankeyView._focusAdjacencyDisabled = true;
                     this.shape.x += dx;
                     this.shape.y += dy;
                     this.dirty();
@@ -234,25 +242,27 @@ export default echarts.extendChartView({
                         localY: this.shape.y / height
                     });
                 };
-        
                 el.draggable = true;
                 el.cursor = 'move';
-
             }
             
             if (itemModel.get('focusNodeAdjacency')) {
                 el.off('mouseover').on('mouseover', function () {
-                    api.dispatchAction({
-                        type: 'focusNodeAdjacency',
-                        seriesId: seriesModel.id,
-                        dataIndex: el.dataIndex
-                    });
+                    if (!sankeyView._focusAdjacencyDisabled) {
+                        api.dispatchAction({
+                            type: 'focusNodeAdjacency',
+                            seriesId: seriesModel.id,
+                            dataIndex: el.dataIndex
+                        });
+                    }
                 });
                 el.off('mouseout').on('mouseout', function () {
-                    api.dispatchAction({
-                        type: 'unfocusNodeAdjacency',
-                        seriesId: seriesModel.id
-                    })
+                    if (!sankeyView._focusAdjacencyDisabled) {
+                        api.dispatchAction({
+                            type: 'unfocusNodeAdjacency',
+                            seriesId: seriesModel.id
+                        });
+                    }
                 });
             }
         });
@@ -261,18 +271,22 @@ export default echarts.extendChartView({
             var edgeModel = edgeData.getItemModel(dataIndex);
             if (edgeModel.get('focusNodeAdjacency')) {
                 el.off('mouseover').on('mouseover', function () {
-                    api.dispatchAction({
-                        type: 'focusNodeAdjacency',
-                        seriesId: seriesModel.id,
-                        edgeDataIndex: el.dataIndex
-                    });
+                    if (!sankeyView._focusAdjacencyDisabled) {
+                        api.dispatchAction({
+                            type: 'focusNodeAdjacency',
+                            seriesId: seriesModel.id,
+                            edgeDataIndex: el.dataIndex
+                        });
+                    }
                 });
                 el.off('mouseout').on('mouseout', function () {
-                    api.dispatchAction({
-                        type: 'unfocusNodeAdjacency',
-                        seriesId: seriesModel.id,
-                    });
-                })
+                    if (!sankeyView._focusAdjacencyDisabled) {
+                        api.dispatchAction({
+                            type: 'unfocusNodeAdjacency',
+                            seriesId: seriesModel.id
+                        });
+                    }
+                });
             }
         });
 


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