From 5c1f6423d039069b1d9f77ecb7838d9504fe5dce Mon Sep 17 00:00:00 2001 From: deqingli Date: Mon, 23 Apr 2018 21:17:45 +0800 Subject: [PATCH] fix when resize the sankey view after drag the node the position of the node won't be changed accordingly --- src/chart/sankey/SankeyView.js | 21 +++++++++++++-------- src/chart/sankey/sankeyLayout.js | 2 +- test/{sankey-jume.html => sankey-jump.html} | 0 3 files changed, 14 insertions(+), 9 deletions(-) rename test/{sankey-jume.html => sankey-jump.html} (100%) diff --git a/src/chart/sankey/SankeyView.js b/src/chart/sankey/SankeyView.js index 045c3a581..180f49144 100644 --- a/src/chart/sankey/SankeyView.js +++ b/src/chart/sankey/SankeyView.js @@ -67,6 +67,11 @@ export default echarts.extendChartView({ var graph = seriesModel.getGraph(); var group = this.group; var layoutInfo = seriesModel.layoutInfo; + // view width + var width = layoutInfo.width; + // view height + var height = layoutInfo.height; + var nodeData = seriesModel.getData(); var edgeData = seriesModel.getData('edge'); @@ -96,10 +101,10 @@ export default echarts.extendChartView({ curve.shape.extent = Math.max(1, edgeLayout.dy); - var x1 = (dragX1 != null ? dragX1 : n1Layout.x) + n1Layout.dx; - var y1 = (dragY1 != null ? dragY1 : n1Layout.y) + edgeLayout.sy + edgeLayout.dy / 2; - var x2 = dragX2 != null ? dragX2 : n2Layout.x; - var y2 = (dragY2 != null ? dragY2 : n2Layout.y) + edgeLayout.ty + edgeLayout.dy / 2; + var x1 = (dragX1 != null ? dragX1 * width : n1Layout.x) + n1Layout.dx; + var y1 = (dragY1 != null ? dragY1 * height : n1Layout.y) + edgeLayout.sy + edgeLayout.dy / 2; + var x2 = dragX2 != null ? dragX2 * width : n2Layout.x; + var y2 = (dragY2 != null ? dragY2 * height : n2Layout.y) + edgeLayout.ty + edgeLayout.dy / 2; var cpx1 = x1 * (1 - curvature) + x2 * curvature; var cpy1 = y1; var cpx2 = x1 * curvature + x2 * (1 - curvature); @@ -145,8 +150,8 @@ export default echarts.extendChartView({ var rect = new graphic.Rect({ shape: { - x: dragX != null ? dragX : layout.x, - y: dragY != null ? dragY : layout.y, + x: dragX != null ? dragX * width : layout.x, + y: dragY != null ? dragY * height : layout.y, width: layout.dx, height: layout.dy }, @@ -187,8 +192,8 @@ export default echarts.extendChartView({ type: 'dragNode', seriesId: seriesModel.id, dataIndex: nodeData.getRawIndex(dataIndex), - localX: this.shape.x, - localY: this.shape.y + localX: this.shape.x / width, + localY: this.shape.y / height }); }; diff --git a/src/chart/sankey/sankeyLayout.js b/src/chart/sankey/sankeyLayout.js index 64fce8e01..455bb4400 100644 --- a/src/chart/sankey/sankeyLayout.js +++ b/src/chart/sankey/sankeyLayout.js @@ -19,7 +19,7 @@ /** * @file The layout algorithm of sankey view - * @author Deqing Li(annong035@gmail.com) + * @author Deqing Li(annong035@gmail.com) */ import * as layout from '../../util/layout'; diff --git a/test/sankey-jume.html b/test/sankey-jump.html similarity index 100% rename from test/sankey-jume.html rename to test/sankey-jump.html -- GitLab