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

[incubator-echarts] branch force-enhance created (now c1507f2)

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

shenyi pushed a change to branch force-enhance
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git.


      at c1507f2  feat(force): Add initial friction config in force layout #11024

This branch includes the following new commits:

     new c1507f2  feat(force): Add initial friction config in force layout #11024

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[incubator-echarts] 01/01: feat(force): Add initial friction config in force layout #11024

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c1507f2b5324b963ad938cb49b4c8e0e2ff1a1e3
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Sep 18 21:54:52 2019 +0800

    feat(force): Add initial friction config in force layout #11024
---
 src/chart/graph/GraphSeries.js | 2 ++
 src/chart/graph/forceHelper.js | 5 +++--
 src/chart/graph/forceLayout.js | 3 ++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/chart/graph/GraphSeries.js b/src/chart/graph/GraphSeries.js
index a69f7ad..2ea09b2 100644
--- a/src/chart/graph/GraphSeries.js
+++ b/src/chart/graph/GraphSeries.js
@@ -215,6 +215,8 @@ var GraphSeries = echarts.extendSeriesModel({
             // Node repulsion. Can be an array to represent range.
             repulsion: [0, 50],
             gravity: 0.1,
+            // Initial friction
+            friction: 0.6,
 
             // Edge length. Can be an array to represent range.
             edgeLength: 30,
diff --git a/src/chart/graph/forceHelper.js b/src/chart/graph/forceHelper.js
index bce7981..291d965 100644
--- a/src/chart/graph/forceHelper.js
+++ b/src/chart/graph/forceHelper.js
@@ -69,11 +69,12 @@ export function forceLayout(nodes, edges, opts) {
     // var k = scale * Math.sqrt(width * height / nodes.length);
     // var k2 = k * k;
 
-    var friction = 0.6;
+    var initialFriction = opts.friction == null ? 0.6 : opts.friction;
+    var friction = initialFriction;
 
     return {
         warmUp: function () {
-            friction = 0.5;
+            friction = initialFriction * 0.8;
         },
 
         setFixed: function (idx) {
diff --git a/src/chart/graph/forceLayout.js b/src/chart/graph/forceLayout.js
index af999bf..53ffcec 100644
--- a/src/chart/graph/forceLayout.js
+++ b/src/chart/graph/forceLayout.js
@@ -95,7 +95,8 @@ export default function (ecModel) {
             var rect = coordSys.getBoundingRect();
             var forceInstance = forceLayout(nodes, edges, {
                 rect: rect,
-                gravity: forceModel.get('gravity')
+                gravity: forceModel.get('gravity'),
+                friction: forceModel.get('friction')
             });
             var oldStep = forceInstance.step;
             forceInstance.step = function (cb) {


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