Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
ac7f2fd6
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,发现更多精彩内容 >>
提交
ac7f2fd6
编写于
9月 09, 2019
作者:
D
deqingli
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/master'
上级
c646d44b
55de79f1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
227 addition
and
25 deletion
+227
-25
src/chart/pie/PieSeries.js
src/chart/pie/PieSeries.js
+4
-1
src/chart/pie/PieView.js
src/chart/pie/PieView.js
+54
-24
test/pie-animation.html
test/pie-animation.html
+169
-0
未找到文件。
src/chart/pie/PieSeries.js
浏览文件 @
ac7f2fd6
...
@@ -170,9 +170,12 @@ var PieSeries = echarts.extendSeriesModel({
...
@@ -170,9 +170,12 @@ var PieSeries = echarts.extendSeriesModel({
borderWidth
:
1
borderWidth
:
1
},
},
// Animation type
canbe
expansion, scale
// Animation type
. Valid values:
expansion, scale
animationType
:
'
expansion
'
,
animationType
:
'
expansion
'
,
// Animation type when update. Valid values: transition, expansion
animationTypeUpdate
:
'
transition
'
,
animationEasing
:
'
cubicOut
'
animationEasing
:
'
cubicOut
'
}
}
});
});
...
...
src/chart/pie/PieView.js
浏览文件 @
ac7f2fd6
...
@@ -112,6 +112,8 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
...
@@ -112,6 +112,8 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
var
sectorShape
=
zrUtil
.
extend
({},
layout
);
var
sectorShape
=
zrUtil
.
extend
({},
layout
);
sectorShape
.
label
=
null
;
sectorShape
.
label
=
null
;
var
animationTypeUpdate
=
seriesModel
.
getShallow
(
'
animationTypeUpdate
'
);
if
(
firstCreate
)
{
if
(
firstCreate
)
{
sector
.
setShape
(
sectorShape
);
sector
.
setShape
(
sectorShape
);
...
@@ -136,9 +138,15 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
...
@@ -136,9 +138,15 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
}
}
else
{
else
{
graphic
.
updateProps
(
sector
,
{
if
(
animationTypeUpdate
===
'
expansion
'
)
{
shape
:
sectorShape
// Sectors are set to be target shape and an overlaying clipPath is used for animation
},
seriesModel
,
idx
);
sector
.
setShape
(
sectorShape
);
}
else
{
// Transition animation from the old shape
graphic
.
updateProps
(
sector
,
{
shape
:
sectorShape
},
seriesModel
,
idx
);
}
}
}
// Update common style
// Update common style
...
@@ -167,7 +175,9 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
...
@@ -167,7 +175,9 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
seriesModel
.
get
(
'
animation
'
)
seriesModel
.
get
(
'
animation
'
)
);
);
this
.
_updateLabel
(
data
,
idx
);
// Label and text animation should be applied only for transition type animation when update
var
withAnimation
=
!
firstCreate
&&
animationTypeUpdate
===
'
transition
'
;
this
.
_updateLabel
(
data
,
idx
,
withAnimation
);
this
.
highDownOnUpdate
=
(
itemModel
.
get
(
'
hoverAnimation
'
)
&&
seriesModel
.
isAnimationEnabled
())
this
.
highDownOnUpdate
=
(
itemModel
.
get
(
'
hoverAnimation
'
)
&&
seriesModel
.
isAnimationEnabled
())
?
function
(
fromState
,
toState
)
{
?
function
(
fromState
,
toState
)
{
...
@@ -201,7 +211,7 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
...
@@ -201,7 +211,7 @@ piePieceProto.updateData = function (data, idx, firstCreate) {
graphic
.
setHoverStyle
(
this
);
graphic
.
setHoverStyle
(
this
);
};
};
piePieceProto
.
_updateLabel
=
function
(
data
,
idx
)
{
piePieceProto
.
_updateLabel
=
function
(
data
,
idx
,
withAnimation
)
{
var
labelLine
=
this
.
childAt
(
1
);
var
labelLine
=
this
.
childAt
(
1
);
var
labelText
=
this
.
childAt
(
2
);
var
labelText
=
this
.
childAt
(
2
);
...
@@ -218,20 +228,33 @@ piePieceProto._updateLabel = function (data, idx) {
...
@@ -218,20 +228,33 @@ piePieceProto._updateLabel = function (data, idx) {
return
;
return
;
}
}
graphic
.
updateProps
(
labelLine
,
{
var
targetLineShape
=
{
shape
:
{
points
:
labelLayout
.
linePoints
||
[
points
:
labelLayout
.
linePoints
||
[
[
labelLayout
.
x
,
labelLayout
.
y
],
[
labelLayout
.
x
,
labelLayout
.
y
],
[
labelLayout
.
x
,
labelLayout
.
y
]
[
labelLayout
.
x
,
labelLayout
.
y
],
[
labelLayout
.
x
,
labelLayout
.
y
],
[
labelLayout
.
x
,
labelLayout
.
y
]
]
]
};
}
var
targetTextStyle
=
{
},
seriesModel
,
idx
);
x
:
labelLayout
.
x
,
y
:
labelLayout
.
y
};
if
(
withAnimation
)
{
graphic
.
updateProps
(
labelLine
,
{
shape
:
targetLineShape
},
seriesModel
,
idx
);
graphic
.
updateProps
(
labelText
,
{
style
:
targetTextStyle
},
seriesModel
,
idx
);
}
else
{
labelLine
.
attr
({
shape
:
targetLineShape
});
labelText
.
attr
({
style
:
targetTextStyle
});
}
graphic
.
updateProps
(
labelText
,
{
style
:
{
x
:
labelLayout
.
x
,
y
:
labelLayout
.
y
}
},
seriesModel
,
idx
);
labelText
.
attr
({
labelText
.
attr
({
rotation
:
labelLayout
.
rotation
,
rotation
:
labelLayout
.
rotation
,
origin
:
[
labelLayout
.
x
,
labelLayout
.
y
],
origin
:
[
labelLayout
.
x
,
labelLayout
.
y
],
...
@@ -309,6 +332,7 @@ var PieView = ChartView.extend({
...
@@ -309,6 +332,7 @@ var PieView = ChartView.extend({
var
hasAnimation
=
ecModel
.
get
(
'
animation
'
);
var
hasAnimation
=
ecModel
.
get
(
'
animation
'
);
var
isFirstRender
=
!
oldData
;
var
isFirstRender
=
!
oldData
;
var
animationType
=
seriesModel
.
get
(
'
animationType
'
);
var
animationType
=
seriesModel
.
get
(
'
animationType
'
);
var
animationTypeUpdate
=
seriesModel
.
get
(
'
animationTypeUpdate
'
);
var
onSectorClick
=
zrUtil
.
curry
(
var
onSectorClick
=
zrUtil
.
curry
(
updateDataSelected
,
this
.
uid
,
seriesModel
,
hasAnimation
,
api
updateDataSelected
,
this
.
uid
,
seriesModel
,
hasAnimation
,
api
...
@@ -334,6 +358,12 @@ var PieView = ChartView.extend({
...
@@ -334,6 +358,12 @@ var PieView = ChartView.extend({
.
update
(
function
(
newIdx
,
oldIdx
)
{
.
update
(
function
(
newIdx
,
oldIdx
)
{
var
piePiece
=
oldData
.
getItemGraphicEl
(
oldIdx
);
var
piePiece
=
oldData
.
getItemGraphicEl
(
oldIdx
);
if
(
!
isFirstRender
&&
animationTypeUpdate
!==
'
transition
'
)
{
piePiece
.
eachChild
(
function
(
child
)
{
child
.
stopAnimation
(
true
);
});
}
piePiece
.
updateData
(
data
,
newIdx
);
piePiece
.
updateData
(
data
,
newIdx
);
piePiece
.
off
(
'
click
'
);
piePiece
.
off
(
'
click
'
);
...
@@ -348,9 +378,8 @@ var PieView = ChartView.extend({
...
@@ -348,9 +378,8 @@ var PieView = ChartView.extend({
.
execute
();
.
execute
();
if
(
if
(
hasAnimation
&&
isFirstRender
&&
data
.
count
()
>
0
hasAnimation
&&
data
.
count
()
>
0
// Default expansion animation
&&
(
isFirstRender
?
animationType
!==
'
scale
'
:
animationTypeUpdate
!==
'
transition
'
)
&&
animationType
!==
'
scale
'
)
{
)
{
var
shape
=
data
.
getItemLayout
(
0
);
var
shape
=
data
.
getItemLayout
(
0
);
for
(
var
s
=
1
;
isNaN
(
shape
.
startAngle
)
&&
s
<
data
.
count
();
++
s
)
{
for
(
var
s
=
1
;
isNaN
(
shape
.
startAngle
)
&&
s
<
data
.
count
();
++
s
)
{
...
@@ -361,7 +390,7 @@ var PieView = ChartView.extend({
...
@@ -361,7 +390,7 @@ var PieView = ChartView.extend({
var
removeClipPath
=
zrUtil
.
bind
(
group
.
removeClipPath
,
group
);
var
removeClipPath
=
zrUtil
.
bind
(
group
.
removeClipPath
,
group
);
group
.
setClipPath
(
this
.
_createClipPath
(
group
.
setClipPath
(
this
.
_createClipPath
(
shape
.
cx
,
shape
.
cy
,
r
,
shape
.
startAngle
,
shape
.
clockwise
,
removeClipPath
,
seriesModel
shape
.
cx
,
shape
.
cy
,
r
,
shape
.
startAngle
,
shape
.
clockwise
,
removeClipPath
,
seriesModel
,
isFirstRender
));
));
}
}
else
{
else
{
...
@@ -375,7 +404,7 @@ var PieView = ChartView.extend({
...
@@ -375,7 +404,7 @@ var PieView = ChartView.extend({
dispose
:
function
()
{},
dispose
:
function
()
{},
_createClipPath
:
function
(
_createClipPath
:
function
(
cx
,
cy
,
r
,
startAngle
,
clockwise
,
cb
,
seriesModel
cx
,
cy
,
r
,
startAngle
,
clockwise
,
cb
,
seriesModel
,
isFirstRender
)
{
)
{
var
clipPath
=
new
graphic
.
Sector
({
var
clipPath
=
new
graphic
.
Sector
({
shape
:
{
shape
:
{
...
@@ -389,7 +418,8 @@ var PieView = ChartView.extend({
...
@@ -389,7 +418,8 @@ var PieView = ChartView.extend({
}
}
});
});
graphic
.
initProps
(
clipPath
,
{
var
initOrUpdate
=
isFirstRender
?
graphic
.
initProps
:
graphic
.
updateProps
;
initOrUpdate
(
clipPath
,
{
shape
:
{
shape
:
{
endAngle
:
startAngle
+
(
clockwise
?
1
:
-
1
)
*
Math
.
PI
*
2
endAngle
:
startAngle
+
(
clockwise
?
1
:
-
1
)
*
Math
.
PI
*
2
}
}
...
...
test/pie-animation.html
0 → 100644
浏览文件 @
ac7f2fd6
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<meta
charset=
"utf-8"
>
<script
src=
"lib/esl.js"
></script>
<script
src=
"lib/config.js"
></script>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
</head>
<body>
<style>
html
,
body
,
#main1
,
#main2
{
width
:
100%
;
height
:
250px
;
margin
:
0
;
}
.test-title
{
background
:
#146402
;
padding
:
10px
;
color
:
#fff
;
}
button
{
padding
:
10px
20px
;
margin
:
10px
;
}
</style>
<div
class=
"test-title"
>
Animation: Transition from previous state to new state, in 10 seconds after clicking Go
</div>
<button
id=
"btn1"
>
Go
</button>
<div
id=
"main1"
></div>
<div
class=
"test-title"
>
Animation: Transition all over again, in 10 seconds after clicking Go
</div>
<button
id=
"btn2"
>
Go
</button>
<div
id=
"main2"
></div>
<script>
require
([
'
echarts
'
],
function
(
echarts
)
{
var
chart
=
echarts
.
init
(
document
.
getElementById
(
'
main1
'
),
null
,
{
renderer
:
'
svg
'
}
);
var
data
=
[
{
"
name
"
:
"
a1
"
,
"
value
"
:
92386
},
{
"
name
"
:
"
b1
"
,
"
value
"
:
90611
},
{
"
name
"
:
"
c1
"
,
"
value
"
:
12596
},
{
"
name
"
:
"
d1
"
,
"
value
"
:
9438
},
{
"
name
"
:
"
e1
"
,
"
value
"
:
10049
}
];
var
data2
=
[
{
"
name
"
:
"
a1
"
,
"
value
"
:
120
},
{
"
name
"
:
"
b1
"
,
"
value
"
:
200
},
{
"
name
"
:
"
c1
"
,
"
value
"
:
300
},
{
"
name
"
:
"
x1
"
,
"
value
"
:
20
},
{
"
name
"
:
"
y1
"
,
"
value
"
:
30
}
];
var
option
=
{
series
:
[{
type
:
'
pie
'
,
animationDuration
:
1000
,
animationDurationUpdate
:
10000
,
startAngle
:
0
,
endAngle
:
360
,
radius
:
[
'
50%
'
,
'
80%
'
],
center
:
[
'
40%
'
,
'
50%
'
],
data
:
data
}]
};
chart
.
setOption
(
option
);
document
.
getElementById
(
'
btn1
'
).
addEventListener
(
'
click
'
,
function
()
{
option
.
series
[
0
].
data
=
data2
;
chart
.
setOption
(
option
,
true
);
});
});
</script>
<script>
require
([
'
echarts
'
],
function
(
echarts
)
{
var
chart
=
echarts
.
init
(
document
.
getElementById
(
'
main2
'
),
null
,
{
renderer
:
'
svg
'
}
);
var
data
=
[
{
"
name
"
:
"
a1
"
,
"
value
"
:
92386
},
{
"
name
"
:
"
b1
"
,
"
value
"
:
90611
},
{
"
name
"
:
"
c1
"
,
"
value
"
:
12596
},
{
"
name
"
:
"
d1
"
,
"
value
"
:
9438
},
{
"
name
"
:
"
e1
"
,
"
value
"
:
10049
}
];
var
data2
=
[
{
"
name
"
:
"
a1
"
,
"
value
"
:
120
},
{
"
name
"
:
"
b1
"
,
"
value
"
:
200
},
{
"
name
"
:
"
c1
"
,
"
value
"
:
300
},
{
"
name
"
:
"
x1
"
,
"
value
"
:
20
},
{
"
name
"
:
"
y1
"
,
"
value
"
:
30
}
];
var
option
=
{
series
:
[{
type
:
'
pie
'
,
animationType
:
'
expansion
'
,
animationDuration
:
1000
,
animationDurationUpdate
:
10000
,
animationTypeUpdate
:
'
expansion
'
,
startAngle
:
0
,
endAngle
:
360
,
radius
:
[
'
50%
'
,
'
80%
'
],
center
:
[
'
40%
'
,
'
50%
'
],
data
:
data
}]
};
chart
.
setOption
(
option
);
document
.
getElementById
(
'
btn2
'
).
addEventListener
(
'
click
'
,
function
()
{
option
.
series
[
0
].
data
=
data2
;
chart
.
setOption
(
option
,
true
);
});
});
</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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录