Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
8925f405
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
8925f405
编写于
4月 15, 2020
作者:
Y
Yi Shen
提交者:
GitHub
4月 15, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12414 from apache/fix-11790
showLoading align center
上级
f6744f13
d26cd1ae
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
90 addition
and
45 deletion
+90
-45
src/loading/default.js
src/loading/default.js
+46
-34
test/loading.html
test/loading.html
+44
-11
未找到文件。
src/loading/default.js
浏览文件 @
8925f405
...
...
@@ -19,6 +19,7 @@
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
*
as
graphic
from
'
../util/graphic
'
;
import
*
as
textContain
from
'
zrender/src/contain/text
'
;
var
PI
=
Math
.
PI
;
...
...
@@ -34,11 +35,16 @@ export default function (api, opts) {
opts
=
opts
||
{};
zrUtil
.
defaults
(
opts
,
{
text
:
'
loading
'
,
color
:
'
#c23531
'
,
textColor
:
'
#000
'
,
fontSize
:
'
12px
'
,
maskColor
:
'
rgba(255, 255, 255, 0.8)
'
,
showSpinner
:
true
,
color
:
'
#c23531
'
,
spinnerRadius
:
10
,
lineWidth
:
5
,
zlevel
:
0
});
var
group
=
new
graphic
.
Group
();
var
mask
=
new
graphic
.
Rect
({
style
:
{
fill
:
opts
.
maskColor
...
...
@@ -46,24 +52,13 @@ export default function (api, opts) {
zlevel
:
opts
.
zlevel
,
z
:
10000
});
var
arc
=
new
graphic
.
Arc
({
shape
:
{
startAngle
:
-
PI
/
2
,
endAngle
:
-
PI
/
2
+
0.1
,
r
:
10
},
style
:
{
stroke
:
opts
.
color
,
lineCap
:
'
round
'
,
lineWidth
:
5
},
zlevel
:
opts
.
zlevel
,
z
:
10001
});
group
.
add
(
mask
);
var
font
=
opts
.
fontSize
+
'
sans-serif
'
;
var
labelRect
=
new
graphic
.
Rect
({
style
:
{
fill
:
'
none
'
,
text
:
opts
.
text
,
font
:
font
,
textPosition
:
'
right
'
,
textDistance
:
10
,
textFill
:
opts
.
textColor
...
...
@@ -71,32 +66,49 @@ export default function (api, opts) {
zlevel
:
opts
.
zlevel
,
z
:
10001
});
arc
.
animateShape
(
true
)
.
when
(
1000
,
{
endAngle
:
PI
*
3
/
2
})
.
start
(
'
circularInOut
'
);
arc
.
animateShape
(
true
)
.
when
(
1000
,
{
startAngle
:
PI
*
3
/
2
})
.
delay
(
300
)
.
start
(
'
circularInOut
'
);
var
group
=
new
graphic
.
Group
();
group
.
add
(
arc
);
group
.
add
(
labelRect
);
group
.
add
(
mask
);
if
(
opts
.
showSpinner
)
{
var
arc
=
new
graphic
.
Arc
({
shape
:
{
startAngle
:
-
PI
/
2
,
endAngle
:
-
PI
/
2
+
0.1
,
r
:
opts
.
spinnerRadius
},
style
:
{
stroke
:
opts
.
color
,
lineCap
:
'
round
'
,
lineWidth
:
opts
.
lineWidth
},
zlevel
:
opts
.
zlevel
,
z
:
10001
});
arc
.
animateShape
(
true
)
.
when
(
1000
,
{
endAngle
:
PI
*
3
/
2
})
.
start
(
'
circularInOut
'
);
arc
.
animateShape
(
true
)
.
when
(
1000
,
{
startAngle
:
PI
*
3
/
2
})
.
delay
(
300
)
.
start
(
'
circularInOut
'
);
group
.
add
(
arc
);
}
// Inject resize
group
.
resize
=
function
()
{
var
cx
=
api
.
getWidth
()
/
2
;
var
textWidth
=
textContain
.
getWidth
(
opts
.
text
,
font
);
var
r
=
opts
.
showSpinner
?
opts
.
spinnerRadius
:
0
;
// cx = (containerWidth - arcDiameter - textDistance - textWidth) / 2
// textDistance needs to be calculated when both animation and text exist
var
cx
=
(
api
.
getWidth
()
-
r
*
2
-
(
opts
.
showSpinner
&&
textWidth
?
10
:
0
)
-
textWidth
)
/
2
// only show the text
-
(
opts
.
showSpinner
?
0
:
textWidth
/
2
);
var
cy
=
api
.
getHeight
()
/
2
;
arc
.
setShape
({
opts
.
showSpinner
&&
arc
.
setShape
({
cx
:
cx
,
cy
:
cy
});
var
r
=
arc
.
shape
.
r
;
labelRect
.
setShape
({
x
:
cx
-
r
,
y
:
cy
-
r
,
...
...
test/loading.html
浏览文件 @
8925f405
...
...
@@ -27,27 +27,60 @@ under the License.
</head>
<body>
<style>
html
,
body
,
#main
{
width
:
100%
;
height
:
100%
;
margin
:
0
;
.chart
{
height
:
200px
;
}
#main
{
background
:
#fff
;
h1
{
font-size
:
20px
;
text-align
:
center
;
background
:
#bbb
;
padding
:
10px
0
;
}
</style>
<div
id=
"main"
></div>
<h1>
use the default values
</h1>
<div
class=
"chart"
id=
"main0"
></div>
<h1>
only show the animation
</h1>
<div
class=
"chart"
id=
"main1"
></div>
<h1>
only show the text
</h1>
<div
class=
"chart"
id=
"main2"
></div>
<h1>
fontSzie: 25px, arcRadius: 12, lineWidth: 8
</h1>
<div
class=
"chart"
id=
"main3"
></div>
<script>
require
([
'
echarts
'
],
function
(
echarts
)
{
var
chart
=
echarts
.
init
(
document
.
getElementById
(
'
main
'
));
chart
.
showLoading
({
text
:
'
暂无数据
'
var
chart0
=
echarts
.
init
(
document
.
getElementById
(
'
main0
'
));
chart0
.
showLoading
();
var
chart1
=
echarts
.
init
(
document
.
getElementById
(
'
main1
'
));
chart1
.
showLoading
({
text
:
''
});
var
chart2
=
echarts
.
init
(
document
.
getElementById
(
'
main2
'
));
chart2
.
showLoading
({
showAnimation
:
false
});
var
chart3
=
echarts
.
init
(
document
.
getElementById
(
'
main3
'
));
chart3
.
showLoading
({
text
:
'
暂无数据
'
,
textColor
:
'
#000
'
,
fontSize
:
'
25px
'
,
maskColor
:
'
rgba(255, 255, 255, 0.8)
'
,
color
:
'
#c23531
'
,
arcRadius
:
12
,
lineWidth
:
8
,
zlevel
:
0
});
window
.
onresize
=
chart
.
resize
;
window
.
onresize
=
function
()
{
chart0
.
resize
();
chart1
.
resize
();
chart2
.
resize
();
chart3
.
resize
();
};
});
</script>
</body>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录