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 2020/06/18 04:48:43 UTC

[GitHub] [incubator-echarts] plainheart commented on a change in pull request #12821: feat(sankey): provide layout with unequal input and output paths

plainheart commented on a change in pull request #12821:
URL: https://github.com/apache/incubator-echarts/pull/12821#discussion_r441963199



##########
File path: src/chart/sankey/SankeyView.js
##########
@@ -132,6 +154,7 @@ export default echarts.extendChartView({
         var width = layoutInfo.width;
         // view height
         var height = layoutInfo.height;
+        var mode = seriesModel.option.mode || 'normal';

Review comment:
       It's suggested to use `seriesModel.get('mode')` instead of `seriesModel.option.mode`.
   ```suggestion
           var mode = seriesModel.get('mode') || 'normal';
   ```

##########
File path: src/chart/sankey/SankeyView.js
##########
@@ -183,14 +219,15 @@ export default echarts.extendChartView({
             }
             else {
                 x1 = (dragX1 != null ? dragX1 * width : n1Layout.x) + n1Layout.dx;
-                y1 = (dragY1 != null ? dragY1 * height : n1Layout.y) + edgeLayout.sy;
+                y1 = (dragY1 != null ? dragY1 * height : n1Layout.y / n1lengthin) + edgeLayout.sy / n1lengthout;
                 x2 = dragX2 != null ? dragX2 * width : n2Layout.x;
-                y2 = (dragY2 != null ? dragY2 * height : n2Layout.y) + edgeLayout.ty;
+                y2 = (dragY2 != null ? dragY2 * height : n2Layout.y / n2lengthout) + edgeLayout.ty / n2lengthin;
                 cpx1 = x1 * (1 - curvature) + x2 * curvature;
                 cpy1 = y1;
                 cpx2 = x1 * curvature + x2 * (1 - curvature);
                 cpy2 = y2;
             }
+            // debugger

Review comment:
       This debugger should be removed.

##########
File path: src/chart/sankey/sankeyLayout.js
##########
@@ -28,6 +28,8 @@ export default function (ecModel, api, payload) {
         var nodeWidth = seriesModel.get('nodeWidth');
         var nodeGap = seriesModel.get('nodeGap');
 
+        var mode = seriesModel.option.mode || 'normal';

Review comment:
       It's suggested to use `seriesModel.get('mode')` instead of `seriesModel.option.mode`.
   ```suggestion
           var mode = seriesModel.get('mode') || 'normal';
   ```

##########
File path: src/chart/sankey/sankeyLayout.js
##########
@@ -82,13 +84,17 @@ function layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iteration
  * Compute the value of each node by summing the associated edge's value
  *
  * @param {module:echarts/data/Graph~Node} nodes  node of sankey view
+ * @param {string} mode  mode of sankey view
  */
-function computeNodeValues(nodes) {
+function computeNodeValues(nodes, mode) {
     zrUtil.each(nodes, function (node) {
         var value1 = sum(node.outEdges, getEdgeValue);
         var value2 = sum(node.inEdges, getEdgeValue);
         var nodeRawValue = node.getValue() || 0;
         var value = Math.max(value1, value2, nodeRawValue);
+        if (mode === 'uneven') {
+          value = nodeRawValue || value;
+        }
         node.setLayout({value: value}, true);
     });

Review comment:
       The judging logic of `mode === 'uneven'` is suggested to move to the place before `zrUtil.each`.
   ```suggestion
       var isUnevenMode = mode === 'uneven';
       zrUtil.each(nodes, function (node) {
           var value1 = sum(node.outEdges, getEdgeValue);
           var value2 = sum(node.inEdges, getEdgeValue);
           var nodeRawValue = node.getValue() || 0;
           var value = Math.max(value1, value2, nodeRawValue);
           if (isUnevenMode) {
             value = nodeRawValue || value;
           }
           node.setLayout({value: value}, true);
       });
   ```




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