Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
2a466930
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 搜索 >>
提交
2a466930
编写于
11月 29, 2017
作者:
O
Ovilia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(sunburst): highlight policy from real config
上级
99c701ab
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
54 addition
and
21 deletion
+54
-21
src/chart/sunburst/SunburstPiece.js
src/chart/sunburst/SunburstPiece.js
+29
-18
src/chart/sunburst/SunburstSeries.js
src/chart/sunburst/SunburstSeries.js
+12
-1
test/sunburst.html
test/sunburst.html
+13
-2
未找到文件。
src/chart/sunburst/SunburstPiece.js
浏览文件 @
2a466930
...
...
@@ -2,10 +2,10 @@ import * as zrUtil from 'zrender/src/core/util';
import
*
as
graphic
from
'
../../util/graphic
'
;
var
NodeHighlightPolicy
=
{
NONE
:
0
,
// not downplay others
DESCENDANT
:
1
,
ANCESTOR
:
2
,
SELF
:
3
NONE
:
'
none
'
,
// not downplay others
DESCENDANT
:
'
descendant
'
,
ANCESTOR
:
'
ancestor
'
,
SELF
:
'
self
'
};
/**
...
...
@@ -28,7 +28,9 @@ function SunburstPiece(node, seriesModel, ecModel) {
this
.
node
=
node
;
this
.
updateData
(
node
,
true
,
seriesModel
,
ecModel
);
var
highlightPolicy
=
seriesModel
.
getShallow
(
'
highlightPolicy
'
);
this
.
updateData
(
true
,
seriesModel
,
ecModel
,
highlightPolicy
);
// Hover to change label and labelLine
function
onEmphasis
()
{
...
...
@@ -48,14 +50,14 @@ function SunburstPiece(node, seriesModel, ecModel) {
var
SunburstPieceProto
=
SunburstPiece
.
prototype
;
SunburstPieceProto
.
updateData
=
function
(
node
,
firstCreate
,
seriesModel
,
ecModel
ecModel
,
highlightPolicy
)
{
var
sector
=
this
.
childAt
(
0
);
// var seriesModel = node.hostModel
;
var
node
=
this
.
node
;
var
itemModel
=
node
.
getModel
();
var
layout
=
node
.
getLayout
();
var
sectorShape
=
zrUtil
.
extend
({},
layout
);
...
...
@@ -100,23 +102,21 @@ SunburstPieceProto.updateData = function (
var
cursorStyle
=
itemModel
.
getShallow
(
'
cursor
'
);
cursorStyle
&&
sector
.
attr
(
'
cursor
'
,
cursorStyle
);
this
.
_initEvents
(
sector
,
node
,
seriesModel
);
this
.
_initEvents
(
sector
,
node
,
seriesModel
,
highlightPolicy
);
// this._updateLabel(data, idx);
graphic
.
setHoverStyle
(
this
);
};
SunburstPieceProto
.
onEmphasis
=
function
()
{
var
policy
=
NodeHighlightPolicy
.
DESCENDANT
;
// TODO: change to real policy
SunburstPieceProto
.
onEmphasis
=
function
(
highlightPolicy
)
{
var
that
=
this
;
this
.
node
.
hostTree
.
root
.
eachNode
(
function
(
n
)
{
if
(
n
.
piece
)
{
if
(
isNodeHighlighted
(
n
,
that
.
node
,
p
olicy
))
{
if
(
isNodeHighlighted
(
n
,
that
.
node
,
highlightP
olicy
))
{
n
.
piece
.
childAt
(
0
).
trigger
(
'
highlight
'
);
}
else
if
(
p
olicy
!==
NodeHighlightPolicy
.
NONE
)
{
else
if
(
highlightP
olicy
!==
NodeHighlightPolicy
.
NONE
)
{
n
.
piece
.
childAt
(
0
).
trigger
(
'
downplay
'
);
}
}
...
...
@@ -140,19 +140,25 @@ SunburstPieceProto.onNormal = function () {
};
SunburstPieceProto
.
onHighlight
=
function
()
{
var
itemStyleModel
=
this
.
node
.
getModel
(
'
itemStyle.highlight
'
);
var
opacity
=
itemStyleModel
.
getItemStyle
().
opacity
||
1
;
var
sector
=
this
.
childAt
(
0
);
sector
.
animateTo
({
style
:
{
opacity
:
1
opacity
:
opacity
}
});
};
SunburstPieceProto
.
onDownplay
=
function
()
{
var
itemStyleModel
=
this
.
node
.
getModel
(
'
itemStyle.downplay
'
);
var
opacity
=
itemStyleModel
.
getItemStyle
().
opacity
||
1
;
var
sector
=
this
.
childAt
(
0
);
sector
.
animateTo
({
style
:
{
opacity
:
0.5
opacity
:
opacity
}
});
};
...
...
@@ -234,14 +240,19 @@ SunburstPieceProto._updateLabel = function (data, idx) {
// });
};
SunburstPieceProto
.
_initEvents
=
function
(
sector
,
node
,
seriesModel
)
{
SunburstPieceProto
.
_initEvents
=
function
(
sector
,
node
,
seriesModel
,
highlightPolicy
)
{
var
itemModel
=
node
.
getModel
();
sector
.
off
(
'
mouseover
'
).
off
(
'
mouseout
'
).
off
(
'
emphasis
'
).
off
(
'
normal
'
);
var
that
=
this
;
var
onEmphasis
=
function
()
{
that
.
onEmphasis
();
that
.
onEmphasis
(
highlightPolicy
);
};
var
onNormal
=
function
()
{
that
.
onNormal
();
...
...
src/chart/sunburst/SunburstSeries.js
浏览文件 @
2a466930
...
...
@@ -68,6 +68,11 @@ export default SeriesModel.extend({
// If still show when all data zero.
stillShowZeroSum
:
true
,
// Policy of highlighting pieces when hover on one
// Valid values: 'none' (for not downplay others), 'descendant',
// 'ancestor', 'self'
highlightPolicy
:
'
descendant
'
,
label
:
{
normal
:
{
// If rotate around circle
...
...
@@ -82,7 +87,13 @@ export default SeriesModel.extend({
borderWidth
:
1
,
borderColor
:
'
white
'
},
emphasis
:
{}
emphasis
:
{},
highlight
:
{
opacity
:
1
},
downplay
:
{
opacity
:
0.6
}
},
// Animation type canbe expansion, scale
...
...
test/sunburst.html
浏览文件 @
2a466930
...
...
@@ -27,6 +27,7 @@
chart
.
setOption
({
series
:
{
type
:
'
sunburst
'
,
highlightPolicy
:
'
ancestor
'
,
data
:
[{
name
:
'
Grandpa
'
,
children
:
[{
...
...
@@ -71,9 +72,19 @@
value
:
5
},
{
name
:
'
Brother Peter
'
,
value
:
1
value
:
1
,
itemStyle
:
{
downplay
:
{
opacity
:
0.1
}
}
}]
}]
}],
itemStyle
:
{
downplay
:
{
opacity
:
0.8
}
}
},
{
name
:
'
Grandpa
\'
s friend Mike
'
,
children
:
[{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录