Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
86150da8
I
incubator-echarts
项目概览
x649585723
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
86150da8
编写于
9月 27, 2017
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the case that some data caused that force layout did not work.
上级
9070ec86
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
175 addition
and
3 deletion
+175
-3
src/chart/graph/GraphSeries.js
src/chart/graph/GraphSeries.js
+1
-1
src/chart/graph/forceLayout.js
src/chart/graph/forceLayout.js
+6
-2
test/force-case.html
test/force-case.html
+168
-0
未找到文件。
src/chart/graph/GraphSeries.js
浏览文件 @
86150da8
...
...
@@ -190,7 +190,7 @@ define(function (require) {
force
:
{
initLayout
:
null
,
// Node repulsion. Can be an array to represent range.
repulsion
:
[
0
,
50
],
repulsion
:
[
1
,
50
],
gravity
:
0.1
,
// Edge length. Can be an array to represent range.
...
...
src/chart/graph/forceLayout.js
浏览文件 @
86150da8
...
...
@@ -49,10 +49,14 @@ define(function (require) {
var
nodes
=
nodeData
.
mapArray
(
'
value
'
,
function
(
value
,
idx
)
{
var
point
=
nodeData
.
getItemLayout
(
idx
);
// var w = numberUtil.linearMap(value, nodeDataExtent, [0, 50]);
var
rep
=
numberUtil
.
linearMap
(
value
,
nodeDataExtent
,
repulsion
);
var
halfRep
=
(
repulsion
[
0
]
+
repulsion
[
1
])
/
2
;
if
(
isNaN
(
rep
))
{
rep
=
(
repulsion
[
0
]
+
repulsion
[
1
])
/
2
;
rep
=
halfRep
;
}
// rep can not be 0.
if
(
rep
<=
0
)
{
rep
=
Math
.
max
(
1
e
-
4
,
Math
.
min
(
1
,
halfRep
));
}
return
{
w
:
rep
,
...
...
test/force-case.html
0 → 100644
浏览文件 @
86150da8
<
!
DOCTYPE
>
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<script
src=
"esl.js"
></script>
<script
src=
"config.js"
></script>
<script
src=
"lib/jquery.min.js"
></script>
<script
src=
"lib/facePrint.js"
></script>
<script
src=
"lib/testHelper.js"
></script>
<link
rel=
"stylesheet"
href=
"reset.css"
>
</head>
<body>
<style>
h1
{
line-height
:
60px
;
height
:
60px
;
background
:
#146402
;
text-align
:
center
;
font-weight
:
bold
;
color
:
#eee
;
font-size
:
14px
;
}
.chart
{
height
:
500px
;
}
</style>
<div
class=
"chart"
id=
"main"
></div>
<script>
var
echarts
;
var
chart
;
var
myChart
;
var
groupCategories
=
[];
var
groupColors
=
[];
require
([
'
echarts
'
,
'
echarts/chart/line
'
,
'
echarts/chart/bar
'
,
'
echarts/chart/pie
'
,
'
echarts/chart/scatter
'
,
'
echarts/chart/map
'
,
'
echarts/chart/parallel
'
,
'
echarts/chart/radar
'
,
'
echarts/chart/graph
'
,
'
echarts/component/grid
'
,
'
echarts/component/polar
'
,
'
echarts/component/geo
'
,
'
echarts/component/singleAxis
'
,
'
echarts/component/legend
'
,
'
echarts/component/tooltip
'
,
'
echarts/component/toolbox
'
,
'
echarts/component/visualMap
'
,
'
echarts/component/dataZoom
'
],
function
(
ec
)
{
echarts
=
ec
;
option
=
{
"
title
"
:
{
"
text
"
:
"
兴趣点
"
,
"
top
"
:
"
top
"
,
"
left
"
:
"
left
"
},
"
tooltip
"
:
{
},
"
legend
"
:
[
{
"
data
"
:
[
"
长期
"
,
"
短期
"
],
"
selected
"
:
{
"
长期
"
:
true
,
"
短期
"
:
true
},
"
orient
"
:
"
vertical
"
,
"
left
"
:
"
right
"
}
],
"
series
"
:
[
{
"
type
"
:
"
graph
"
,
"
layout
"
:
"
force
"
,
"
data
"
:
[
{
"
name
"
:
"
戴胜
"
,
"
value
"
:
31
,
"
symbolSize
"
:
0.6
,
"
category
"
:
1
,
"
x
"
:
null
,
"
y
"
:
null
,
"
label
"
:
{
"
normal
"
:
{
"
position
"
:
"
right
"
,
"
show
"
:
true
}
}
},
{
"
name
"
:
"
石榴
"
,
"
value
"
:
30
,
"
symbolSize
"
:
0.3
,
"
category
"
:
1
,
"
x
"
:
null
,
"
y
"
:
null
,
"
label
"
:
{
"
normal
"
:
{
"
position
"
:
"
right
"
,
"
show
"
:
true
}
}
},
{
"
name
"
:
"
水果
"
,
"
value
"
:
30
,
"
symbolSize
"
:
0.3
,
"
category
"
:
1
,
"
x
"
:
null
,
"
y
"
:
null
,
"
label
"
:
{
"
normal
"
:
{
"
position
"
:
"
right
"
,
"
show
"
:
true
}
}
}
],
"
links
"
:
[
{
"
source
"
:
"
石榴
"
,
"
target
"
:
"
水果
"
}
],
"
categories
"
:
[
{
"
key
"
:
"
longAttentionList
"
,
"
name
"
:
"
长期
"
},
{
"
key
"
:
"
shortAttentionList
"
,
"
name
"
:
"
短期
"
}
],
"
roam
"
:
true
,
"
focusNodeAdjacency
"
:
true
,
"
label
"
:
{
"
emphasis
"
:
{
"
position
"
:
"
right
"
,
"
show
"
:
true
}
},
"
lineStyle
"
:
{
"
normal
"
:
{
"
width
"
:
0.5
,
"
curveness
"
:
0.3
,
"
opacity
"
:
0.7
}
}
}
]
};
testHelper
.
createChart
(
echarts
,
'
main
'
,
option
);
});
</script>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录