Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
df1d9d8e
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,发现更多精彩内容 >>
提交
df1d9d8e
编写于
11月 01, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve graph roam
上级
d140ddc7
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
159 addition
and
53 deletion
+159
-53
src/action/geoRoam.js
src/action/geoRoam.js
+12
-39
src/action/roamHelper.js
src/action/roamHelper.js
+40
-0
src/chart/graph.js
src/chart/graph.js
+2
-0
src/chart/graph/GraphSeries.js
src/chart/graph/GraphSeries.js
+34
-9
src/chart/graph/GraphView.js
src/chart/graph/GraphView.js
+25
-3
src/chart/graph/roamAction.js
src/chart/graph/roamAction.js
+40
-0
src/echarts.js
src/echarts.js
+2
-1
test/graph.html
test/graph.html
+4
-1
未找到文件。
src/action/geoRoam.js
浏览文件 @
df1d9d8e
define
(
function
(
require
)
{
define
(
function
(
require
)
{
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
roamHelper
=
require
(
'
./roamHelper
'
);
var
echarts
=
require
(
'
../
../
echarts
'
);
var
echarts
=
require
(
'
../echarts
'
);
var
actionInfo
=
{
var
actionInfo
=
{
type
:
'
geoRoam
'
,
type
:
'
geoRoam
'
,
event
:
'
geoRoam
'
,
event
:
'
geoRoam
'
,
...
@@ -24,58 +25,30 @@ define(function (require) {
...
@@ -24,58 +25,30 @@ define(function (require) {
ecModel
.
eachComponent
(
componentType
,
function
(
componentModel
)
{
ecModel
.
eachComponent
(
componentType
,
function
(
componentModel
)
{
if
(
componentModel
.
name
===
payload
.
name
)
{
if
(
componentModel
.
name
===
payload
.
name
)
{
var
dx
=
payload
.
dx
;
var
dy
=
payload
.
dy
;
var
zoom
=
payload
.
zoom
;
var
geo
=
componentModel
.
coordinateSystem
;
var
geo
=
componentModel
.
coordinateSystem
;
if
(
geo
.
type
!==
'
geo
'
)
{
if
(
geo
.
type
!==
'
geo
'
)
{
return
;
return
;
}
}
var
roamDetailModel
=
componentModel
.
getModel
(
'
roamDetail
'
);
var
roamDetailModel
=
componentModel
.
getModel
(
'
roamDetail
'
);
var
panX
=
roamDetailModel
.
get
(
'
x
'
)
||
0
;
var
res
=
roamHelper
.
calcPanAndZoom
(
roamDetailModel
,
payload
);
var
panY
=
roamDetailModel
.
get
(
'
y
'
)
||
0
;
var
previousZoom
=
roamDetailModel
.
get
(
'
zoom
'
)
||
1
;
if
(
dx
!=
null
&&
dy
!=
null
)
{
// FIXME Must divide mapScale ?
panX
+=
dx
;
panY
+=
dy
;
componentModel
.
setRoamPan
componentModel
.
setRoamPan
&&
componentModel
.
setRoamPan
(
panX
,
panY
);
&&
componentModel
.
setRoamPan
(
res
.
x
,
res
.
y
);
geo
&&
geo
.
setPan
(
panX
,
panY
);
}
if
(
zoom
!=
null
)
{
var
fixX
=
(
payload
.
originX
-
panX
)
*
(
zoom
-
1
);
var
fixY
=
(
payload
.
originY
-
panY
)
*
(
zoom
-
1
);
panX
-=
fixX
;
panY
-=
fixY
;
geo
&&
geo
.
setPan
(
panX
,
panY
);
componentModel
.
setRoamPan
&&
componentModel
.
setRoamPan
(
panX
,
panY
);
geo
&&
geo
.
setZoom
(
zoom
*
previousZoom
);
componentModel
.
setRoamZoom
componentModel
.
setRoamZoom
&&
componentModel
.
setRoamZoom
(
zoom
*
previousZoom
);
&&
componentModel
.
setRoamZoom
(
res
.
zoom
);
}
geo
&&
geo
.
setPan
(
res
.
x
,
res
.
y
);
geo
&&
geo
.
setZoom
(
res
.
zoom
);
// All map series with same `map` use the same geo coordinate system
// All map series with same `map` use the same geo coordinate system
// So the roamDetail must be in sync. Include the series not selected by legend
// So the roamDetail must be in sync. Include the series not selected by legend
if
(
componentType
===
'
series
'
)
{
if
(
componentType
===
'
series
'
)
{
zrUtil
.
each
(
componentModel
.
seriesGroup
,
function
(
seriesModel
)
{
zrUtil
.
each
(
componentModel
.
seriesGroup
,
function
(
seriesModel
)
{
if
(
dx
!=
null
&&
dy
!=
null
)
{
seriesModel
.
setRoamPan
(
res
.
x
,
res
.
y
);
seriesModel
.
setRoamPan
(
panX
,
panY
);
seriesModel
.
setRoamZoom
(
res
.
zoom
);
}
});
if
(
zoom
!=
null
)
{
seriesModel
.
setRoamZoom
(
zoom
*
previousZoom
);
}
})
}
}
}
}
});
});
...
...
src/action/roamHelper.js
0 → 100644
浏览文件 @
df1d9d8e
define
(
function
(
require
)
{
var
roamHelper
=
{};
/**
* Calculate pan and zoom which from roamDetail model
* @param {module:echarts/model/Model} roamDetailModel
* @param {Object} payload
*/
roamHelper
.
calcPanAndZoom
=
function
(
roamDetailModel
,
payload
)
{
var
dx
=
payload
.
dx
;
var
dy
=
payload
.
dy
;
var
zoom
=
payload
.
zoom
;
var
panX
=
roamDetailModel
.
get
(
'
x
'
)
||
0
;
var
panY
=
roamDetailModel
.
get
(
'
y
'
)
||
0
;
var
previousZoom
=
roamDetailModel
.
get
(
'
zoom
'
)
||
1
;
if
(
dx
!=
null
&&
dy
!=
null
)
{
panX
+=
dx
;
panY
+=
dy
;
}
if
(
zoom
!=
null
)
{
var
fixX
=
(
payload
.
originX
-
panX
)
*
(
zoom
-
1
);
var
fixY
=
(
payload
.
originY
-
panY
)
*
(
zoom
-
1
);
panX
-=
fixX
;
panY
-=
fixY
;
}
return
{
x
:
panX
,
y
:
panY
,
zoom
:
(
zoom
||
1
)
*
previousZoom
};
};
return
roamHelper
;
});
\ No newline at end of file
src/chart/graph.js
浏览文件 @
df1d9d8e
...
@@ -6,6 +6,8 @@ define(function (require) {
...
@@ -6,6 +6,8 @@ define(function (require) {
require
(
'
./graph/GraphSeries
'
);
require
(
'
./graph/GraphSeries
'
);
require
(
'
./graph/GraphView
'
);
require
(
'
./graph/GraphView
'
);
require
(
'
./graph/roamAction
'
);
echarts
.
registerProcessor
(
'
filter
'
,
require
(
'
./graph/categoryFilter
'
));
echarts
.
registerProcessor
(
'
filter
'
,
require
(
'
./graph/categoryFilter
'
));
echarts
.
registerVisualCoding
(
'
chart
'
,
zrUtil
.
curry
(
echarts
.
registerVisualCoding
(
'
chart
'
,
zrUtil
.
curry
(
...
...
src/chart/graph/GraphSeries.js
浏览文件 @
df1d9d8e
...
@@ -8,12 +8,14 @@ define(function (require) {
...
@@ -8,12 +8,14 @@ define(function (require) {
var
createGraphFromNodeEdge
=
require
(
'
../helper/createGraphFromNodeEdge
'
);
var
createGraphFromNodeEdge
=
require
(
'
../helper/createGraphFromNodeEdge
'
);
var
seriesModelProto
=
SeriesModel
.
prototype
;
return
SeriesModel
.
extend
({
return
SeriesModel
.
extend
({
type
:
'
series.graph
'
,
type
:
'
series.graph
'
,
init
:
function
(
option
)
{
init
:
function
(
option
)
{
SeriesModel
.
prototype
.
init
.
apply
(
this
,
arguments
);
seriesModelProto
.
init
.
apply
(
this
,
arguments
);
this
.
_udpateCategoriesData
();
this
.
_udpateCategoriesData
();
...
@@ -24,7 +26,7 @@ define(function (require) {
...
@@ -24,7 +26,7 @@ define(function (require) {
},
},
mergeOption
:
function
(
option
)
{
mergeOption
:
function
(
option
)
{
SeriesModel
.
prototype
.
mergeOption
.
apply
(
this
,
arguments
);
seriesModelProto
.
mergeOption
.
apply
(
this
,
arguments
);
this
.
_udpateCategoriesData
();
this
.
_udpateCategoriesData
();
},
},
...
@@ -76,7 +78,13 @@ define(function (require) {
...
@@ -76,7 +78,13 @@ define(function (require) {
symbol
:
'
circle
'
,
symbol
:
'
circle
'
,
symbolSize
:
10
,
symbolSize
:
10
,
roam
:
true
,
// roam: false,
roamDetail
:
{
x
:
0
,
y
:
0
,
zoom
:
1
},
// Symbol size scale ratio in roam
// Symbol size scale ratio in roam
nodeScaleRatio
:
0.6
,
nodeScaleRatio
:
0.6
,
...
@@ -104,10 +112,8 @@ define(function (require) {
...
@@ -104,10 +112,8 @@ define(function (require) {
},
},
itemStyle
:
{
itemStyle
:
{
normal
:
{
normal
:
{},
},
emphasis
:
{}
emphasis
:
{
}
},
},
lineStyle
:
{
lineStyle
:
{
...
@@ -117,8 +123,27 @@ define(function (require) {
...
@@ -117,8 +123,27 @@ define(function (require) {
curveness
:
0
,
curveness
:
0
,
opacity
:
0.5
opacity
:
0.5
},
},
emphasis
:
{
emphasis
:
{
}
}
}
},
/**
* @param {number} zoom
*/
setRoamZoom
:
function
(
zoom
)
{
var
roamDetail
=
this
.
option
.
roamDetail
;
roamDetail
&&
(
roamDetail
.
zoom
=
zoom
);
},
/**
* @param {number} x
* @param {number} y
*/
setRoamPan
:
function
(
x
,
y
)
{
var
roamDetail
=
this
.
option
.
roamDetail
;
if
(
roamDetail
)
{
roamDetail
.
x
=
x
;
roamDetail
.
y
=
y
;
}
}
}
}
});
});
...
...
src/chart/graph/GraphView.js
浏览文件 @
df1d9d8e
...
@@ -13,13 +13,14 @@ define(function (require) {
...
@@ -13,13 +13,14 @@ define(function (require) {
var
lineDraw
=
new
LineDraw
();
var
lineDraw
=
new
LineDraw
();
var
group
=
this
.
group
;
var
group
=
this
.
group
;
var
controller
=
new
RoamController
(
api
.
getZr
(),
group
);
group
.
add
(
symbolDraw
.
group
);
group
.
add
(
symbolDraw
.
group
);
group
.
add
(
lineDraw
.
group
);
group
.
add
(
lineDraw
.
group
);
this
.
_symbolDraw
=
symbolDraw
;
this
.
_symbolDraw
=
symbolDraw
;
this
.
_lineDraw
=
lineDraw
;
this
.
_lineDraw
=
lineDraw
;
this
.
_controller
=
controller
;
this
.
_controller
=
new
RoamController
(
api
.
getZr
(),
group
);
},
},
render
:
function
(
seriesModel
,
ecModel
,
api
)
{
render
:
function
(
seriesModel
,
ecModel
,
api
)
{
...
@@ -68,7 +69,28 @@ define(function (require) {
...
@@ -68,7 +69,28 @@ define(function (require) {
controller
.
disable
();
controller
.
disable
();
seriesModel
.
get
(
'
roam
'
)
&&
controller
.
enable
();
seriesModel
.
get
(
'
roam
'
)
&&
controller
.
enable
();
controller
.
on
(
'
zoom
'
,
this
.
_updateNodeAndLinkScale
,
this
);
controller
.
off
(
'
pan
'
)
.
off
(
'
zoom
'
)
.
on
(
'
pan
'
,
function
(
dx
,
dy
)
{
api
.
dispatch
({
name
:
seriesModel
.
name
,
type
:
'
graphRoam
'
,
dx
:
dx
,
dy
:
dy
});
})
.
on
(
'
zoom
'
,
function
(
zoom
,
mouseX
,
mouseY
)
{
api
.
dispatch
({
name
:
seriesModel
.
name
,
type
:
'
graphRoam
'
,
zoom
:
zoom
,
originX
:
mouseX
,
originY
:
mouseY
});
})
.
on
(
'
zoom
'
,
this
.
_updateNodeAndLinkScale
,
this
);
},
},
_updateNodeAndLinkScale
:
function
()
{
_updateNodeAndLinkScale
:
function
()
{
...
...
src/chart/graph/roamAction.js
0 → 100644
浏览文件 @
df1d9d8e
define
(
function
(
require
)
{
var
echarts
=
require
(
'
../../echarts
'
);
var
roamHelper
=
require
(
'
../../action/roamHelper
'
);
var
actionInfo
=
{
type
:
'
graphRoam
'
,
event
:
'
graphRoam
'
,
update
:
'
none
'
};
/**
* @payload
* @property {string} name Series name
* @property {number} [dx]
* @property {number} [dy]
* @property {number} [zoom]
* @property {number} [originX]
* @property {number} [originY]
*/
echarts
.
registerAction
(
actionInfo
,
function
(
payload
,
ecModel
)
{
var
seriesModel
=
ecModel
.
getSeriesByName
(
payload
.
name
);
if
(
seriesModel
)
{
var
coordSys
=
seriesModel
.
coordinateSystem
;
var
roamDetailModel
=
seriesModel
.
getModel
(
'
roamDetail
'
);
var
res
=
roamHelper
.
calcPanAndZoom
(
roamDetailModel
,
payload
);
seriesModel
.
setRoamPan
&&
seriesModel
.
setRoamPan
(
res
.
x
,
res
.
y
);
seriesModel
.
setRoamZoom
&&
seriesModel
.
setRoamZoom
(
res
.
zoom
);
coordSys
&&
coordSys
.
setPan
(
res
.
x
,
res
.
y
);
coordSys
&&
coordSys
.
setZoom
(
res
.
zoom
);
}
});
});
\ No newline at end of file
src/echarts.js
浏览文件 @
df1d9d8e
...
@@ -253,8 +253,9 @@ define(function (require) {
...
@@ -253,8 +253,9 @@ define(function (require) {
dispatch
:
function
(
payload
)
{
dispatch
:
function
(
payload
)
{
var
actionWrap
=
actions
[
payload
.
type
];
var
actionWrap
=
actions
[
payload
.
type
];
if
(
actionWrap
)
{
if
(
actionWrap
)
{
var
updateMethod
=
actionWrap
.
actionInfo
.
update
||
'
update
'
;
actionWrap
.
action
(
payload
,
this
.
_model
);
actionWrap
.
action
(
payload
,
this
.
_model
);
this
[
actionWrap
.
actionInfo
.
update
||
'
update
'
](
payload
);
updateMethod
!==
'
none
'
&&
this
[
updateMethod
](
payload
);
}
}
},
},
...
...
test/graph.html
浏览文件 @
df1d9d8e
...
@@ -53,7 +53,9 @@
...
@@ -53,7 +53,9 @@
chart
.
setOption
({
chart
.
setOption
({
tooltip
:
{},
tooltip
:
{},
legend
:
[{
legend
:
[{
data
:
categories
.
map
(
function
(
a
)
{
return
a
.
name
})
data
:
categories
.
map
(
function
(
a
)
{
return
a
.
name
;
})
}],
}],
dataRange
:
{
dataRange
:
{
max
:
100
,
max
:
100
,
...
@@ -68,6 +70,7 @@
...
@@ -68,6 +70,7 @@
data
:
graph
.
nodes
,
data
:
graph
.
nodes
,
links
:
graph
.
links
,
links
:
graph
.
links
,
categories
:
categories
,
categories
:
categories
,
roam
:
true
,
label
:
{
label
:
{
normal
:
{
normal
:
{
position
:
'
right
'
position
:
'
right
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录