力导向默认关闭 worker, 布局比例调整
diff --git a/doc/doc.html b/doc/doc.html
index a9feee8..1bd92f1 100644
--- a/doc/doc.html
+++ b/doc/doc.html
@@ -2870,7 +2870,7 @@
</tr>
<tr>
<td> <b>{boolean}</b> useWorker </td>
- <td> true </td>
+ <td> false </td>
<td> 是否在浏览器支持 web worker 的时候把布局计算放入 web worker 中 </td>
</tr>
<tr>
diff --git a/doc/example/force1.html b/doc/example/force1.html
index d8043b4..7571bfc 100644
--- a/doc/example/force1.html
+++ b/doc/example/force1.html
@@ -105,7 +105,7 @@
minRadius : 15,
maxRadius : 25,
gravity: 1.1,
- scaling: 1.2,
+ scaling: 1.1,
linkSymbol: 'arrow',
nodes:[
{category:0, name: '乔布斯', value : 10},
diff --git a/doc/example/webkit-dep.html b/doc/example/webkit-dep.html
index 7ffd5dc..e50a97d 100644
--- a/doc/example/webkit-dep.html
+++ b/doc/example/webkit-dep.html
@@ -77,6 +77,7 @@
webkitDepData.scaling = 1.1;
webkitDepData.steps = 20;
webkitDepData.large = true;
+ webkitDepData.useWorker = true;
webkitDepData.coolDown = 0.995;
webkitDepData.itemStyle = {
normal : {
diff --git a/src/chart/force.js b/src/chart/force.js
index 08e07da..b259079 100644
--- a/src/chart/force.js
+++ b/src/chart/force.js
@@ -363,8 +363,8 @@
var config = {
center: center,
- width: width,
- height: height,
+ width: serie.ratioScaling ? width : size,
+ height: serie.ratioScaling ? height : size,
scaling: serie.scaling || 1.0,
gravity: serie.gravity || 1.0,
barnesHutOptimize: serie.large
diff --git a/src/chart/forceLayoutWorker.js b/src/chart/forceLayoutWorker.js
index 9e67663..fae9aeb 100644
--- a/src/chart/forceLayoutWorker.js
+++ b/src/chart/forceLayoutWorker.js
@@ -642,13 +642,13 @@
// vec2.sub(v, this._rootRegion.centerOfMass, node.position);
// vec2.negate(v, node.position);
vec2.sub(v, this.center, node.position);
- // if (this.width > this.height) {
- // // Stronger gravity on y axis
- // v[1] *= this.width / this.height;
- // } else {
- // // Stronger gravity on x axis
- // v[0] *= this.height / this.width;
- // }
+ if (this.width > this.height) {
+ // Stronger gravity on y axis
+ v[1] *= this.width / this.height;
+ } else {
+ // Stronger gravity on x axis
+ v[0] *= this.height / this.width;
+ }
var d = vec2.len(v) / 100;
if (this.strongGravity) {
diff --git a/src/config.js b/src/config.js
index ed89f45..6240dce 100644
--- a/src/config.js
+++ b/src/config.js
@@ -796,13 +796,16 @@
minRadius : 10,
maxRadius : 20,
+ // 是否根据屏幕比例拉伸
+ ratioScaling: false,
+
// 在 500+ 顶点的图上建议设置 large 为 true, 会使用 Barnes-Hut simulation
// 同时开启 useWorker 并且把 steps 值调大
// 关于Barnes-Hut simulation: http://en.wikipedia.org/wiki/Barnes–Hut_simulation
large: false,
- // 为 false 的时候强制关闭 web worker
- useWorker: true,
+ // 是否在浏览器支持 worker 的时候使用 web worker
+ useWorker: false,
// 每一帧 force 迭代的次数,仅在启用webworker的情况下有用
steps: 1,