Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
6a50ca47
I
incubator-echarts
项目概览
半栈学徒
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
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,发现更多精彩内容 >>
提交
6a50ca47
编写于
12月 14, 2017
作者:
O
Ovilia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(sunburst): improve sorting
上级
fc13cbf8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
44 addition
and
20 deletion
+44
-20
src/chart/sunburst/SunburstPiece.js
src/chart/sunburst/SunburstPiece.js
+2
-1
src/chart/sunburst/SunburstSeries.js
src/chart/sunburst/SunburstSeries.js
+14
-3
src/chart/sunburst/SunburstView.js
src/chart/sunburst/SunburstView.js
+7
-0
src/chart/sunburst/sunburstLayout.js
src/chart/sunburst/sunburstLayout.js
+21
-16
未找到文件。
src/chart/sunburst/SunburstPiece.js
浏览文件 @
6a50ca47
...
...
@@ -295,7 +295,8 @@ function getNodeColor(node, seriesModel, ecModel) {
var
color
=
node
.
getModel
(
'
itemStyle.normal
'
).
get
(
'
color
'
);
if
(
!
color
)
{
// First-generation color
color
=
ecModel
.
option
.
color
[
getRootId
(
node
)];
var
length
=
ecModel
.
option
.
color
.
length
;
color
=
ecModel
.
option
.
color
[
getRootId
(
node
)
%
length
];
}
return
color
;
...
...
src/chart/sunburst/SunburstSeries.js
浏览文件 @
6a50ca47
...
...
@@ -76,6 +76,8 @@ export default SeriesModel.extend({
// 'zoomToNode', 'link', or false
nodeClick
:
'
zoomToNode
'
,
renderLabelForZeroData
:
false
,
label
:
{
normal
:
{
// could be: 'radial', 'tangential', or 'none'
...
...
@@ -114,9 +116,18 @@ export default SeriesModel.extend({
levels
:
[],
// null for not sorting,
// 'desc' and 'asc' for descend and ascendant order
sortOrder
:
'
desc
'
/**
* Sort order.
*
* Valid values: 'desc', 'asc', null, or callback function.
* 'desc' and 'asc' for descend and ascendant order;
* null for not sorting;
* example of callback function:
* function(nodeA, nodeB) {
* return nodeA.getValue() - nodeB.getValue();
* }
*/
sort
:
'
desc
'
},
getViewRoot
:
function
()
{
...
...
src/chart/sunburst/SunburstView.js
浏览文件 @
6a50ca47
...
...
@@ -31,6 +31,8 @@ var SunburstView = ChartView.extend({
var
group
=
this
.
group
;
var
renderLabelForZeroData
=
seriesModel
.
get
(
'
renderLabelForZeroData
'
);
dualTravel
(
newRoot
?
[
newRoot
]
:
[],
oldRoot
?
[
oldRoot
]
:
[]
...
...
@@ -71,6 +73,11 @@ var SunburstView = ChartView.extend({
}
function
doRenderNode
(
newNode
,
oldNode
)
{
if
(
!
renderLabelForZeroData
&&
newNode
&&
!
newNode
.
getValue
())
{
// Not render data with value 0
newNode
=
null
;
}
if
(
newNode
!==
virtualRoot
)
{
if
(
oldNode
&&
oldNode
.
piece
)
{
if
(
newNode
)
{
...
...
src/chart/sunburst/sunburstLayout.js
浏览文件 @
6a50ca47
...
...
@@ -25,8 +25,6 @@ export default function (seriesType, ecModel, api, payload) {
var
r0
=
parsePercent
(
radius
[
0
],
size
/
2
);
var
r
=
parsePercent
(
radius
[
1
],
size
/
2
);
// var data = seriesModel.getData();
var
startAngle
=
-
seriesModel
.
get
(
'
startAngle
'
)
*
RADIAN
;
var
minAngle
=
seriesModel
.
get
(
'
minAngle
'
)
*
RADIAN
;
...
...
@@ -34,9 +32,9 @@ export default function (seriesType, ecModel, api, payload) {
var
treeRoot
=
seriesModel
.
getViewRoot
();
var
rootDepth
=
treeRoot
.
depth
;
var
sort
Order
=
seriesModel
.
get
(
'
sortOrder
'
);
if
(
sort
Order
!=
null
)
{
initChildren
(
treeRoot
,
sort
Order
===
'
asc
'
);
var
sort
=
seriesModel
.
get
(
'
sort
'
);
if
(
sort
!=
null
)
{
initChildren
(
treeRoot
,
sort
);
}
var
validDataCount
=
0
;
...
...
@@ -49,7 +47,7 @@ export default function (seriesType, ecModel, api, payload) {
var
unitRadian
=
Math
.
PI
/
(
sum
||
validDataCount
)
*
2
;
var
renderRollupNode
=
treeRoot
!==
virtualRoot
;
var
levels
=
treeRoot
.
height
+
(
renderRollupNode
?
1
:
0
);
var
levels
=
treeRoot
.
height
-
(
renderRollupNode
?
0
:
1
);
var
rPerLevel
=
(
r
-
r0
)
/
(
levels
||
1
);
var
clockwise
=
seriesModel
.
get
(
'
clockwise
'
);
...
...
@@ -90,7 +88,7 @@ export default function (seriesType, ecModel, api, payload) {
endAngle
=
startAngle
+
dir
*
angle
;
var
depth
=
node
.
depth
-
rootDepth
+
(
renderRollupNode
?
1
:
0
);
var
depth
=
node
.
depth
-
rootDepth
-
(
renderRollupNode
?
0
:
1
);
var
rStart
=
r0
+
rPerLevel
*
depth
;
var
rEnd
=
r0
+
rPerLevel
*
(
depth
+
1
);
...
...
@@ -170,14 +168,21 @@ function initChildren(node, isAsc) {
/**
* Sort children nodes
*
* @param {TreeNode[]} children children of node to be sorted
* @param {boolean} isAsc if is in ascendant order
* @param {TreeNode[]} children children of node to be sorted
* @param {string | function | null} sort sort method
* See SunburstSeries.js for details.
*/
function
sort
(
children
,
isAsc
)
{
return
children
.
sort
(
function
(
a
,
b
)
{
var
diff
=
(
a
.
getValue
()
-
b
.
getValue
())
*
(
isAsc
?
-
1
:
1
);
return
diff
===
0
?
(
a
.
dataIndex
-
b
.
dataIndex
)
*
(
isAsc
?
1
:
-
1
)
:
diff
;
});
function
sort
(
children
,
sortOrder
)
{
if
(
typeof
sortOrder
===
'
function
'
)
{
return
children
.
sort
(
sortOrder
);
}
else
{
var
isAsc
=
sortOrder
===
'
asc
'
;
return
children
.
sort
(
function
(
a
,
b
)
{
var
diff
=
(
a
.
getValue
()
-
b
.
getValue
())
*
(
isAsc
?
1
:
-
1
);
return
diff
===
0
?
(
a
.
dataIndex
-
b
.
dataIndex
)
*
(
isAsc
?
-
1
:
1
)
:
diff
;
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录