Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
bc012f0f
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,发现更多精彩内容 >>
提交
bc012f0f
编写于
7月 15, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(sunburst): adjust default color strategy
上级
b02066d0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
42 deletion
+75
-42
src/chart/sunburst/SunburstSeries.ts
src/chart/sunburst/SunburstSeries.ts
+0
-2
src/chart/sunburst/sunburstVisual.ts
src/chart/sunburst/sunburstVisual.ts
+27
-0
test/data/basicChartsOptions.js
test/data/basicChartsOptions.js
+48
-40
未找到文件。
src/chart/sunburst/SunburstSeries.ts
浏览文件 @
bc012f0f
...
...
@@ -118,8 +118,6 @@ class SunburstSeriesModel extends SeriesModel<SunburstSeriesOption> {
private
_viewRoot
:
TreeNode
;
useColorPaletteOnData
=
true
;
getInitialData
(
option
:
SunburstSeriesOption
,
ecModel
:
GlobalModel
)
{
// Create a virtual root.
const
root
=
{
name
:
option
.
name
,
children
:
option
.
data
};
...
...
src/chart/sunburst/sunburstVisual.ts
浏览文件 @
bc012f0f
...
...
@@ -20,14 +20,41 @@
import
GlobalModel
from
'
../../model/Global
'
;
import
SunburstSeriesModel
,
{
SunburstSeriesNodeItemOption
}
from
'
./SunburstSeries
'
;
import
{
extend
}
from
'
zrender/src/core/util
'
;
import
{
Dictionary
,
ColorString
}
from
'
../../util/types
'
;
import
{
TreeNode
}
from
'
../../data/Tree
'
;
import
{
lift
}
from
'
zrender/src/tool/color
'
;
export
default
function
(
ecModel
:
GlobalModel
)
{
const
paletteScope
:
Dictionary
<
ColorString
>
=
{};
// Default color strategy
function
pickColor
(
node
:
TreeNode
,
seriesModel
:
SunburstSeriesModel
,
treeHeight
:
number
)
{
// Choose color from palette based on the first level.
let
current
=
node
;
while
(
current
&&
current
.
depth
>
1
)
{
current
=
current
.
parentNode
;
}
let
color
=
seriesModel
.
getColorFromPalette
((
current
.
name
||
current
.
dataIndex
+
''
),
paletteScope
);
if
(
node
.
depth
>
1
&&
typeof
color
===
'
string
'
)
{
// Lighter on the deeper level.
color
=
lift
(
color
,
(
node
.
depth
-
1
)
/
(
treeHeight
-
1
)
*
0.5
);
}
return
color
;
}
ecModel
.
eachSeriesByType
(
'
sunburst
'
,
function
(
seriesModel
:
SunburstSeriesModel
)
{
const
data
=
seriesModel
.
getData
();
const
tree
=
data
.
tree
;
tree
.
eachNode
(
function
(
node
)
{
const
model
=
node
.
getModel
<
SunburstSeriesNodeItemOption
>
();
const
style
=
model
.
getModel
(
'
itemStyle
'
).
getItemStyle
();
if
(
!
style
.
fill
)
{
style
.
fill
=
pickColor
(
node
,
seriesModel
,
tree
.
root
.
height
);
}
const
existsStyle
=
data
.
ensureUniqueItemVisual
(
node
.
dataIndex
,
'
style
'
);
extend
(
existsStyle
,
style
);
});
...
...
test/data/basicChartsOptions.js
浏览文件 @
bc012f0f
...
...
@@ -361,12 +361,6 @@ window.allChartsOptions = [
data
:
data
,
label
:
{
show
:
true
},
emphasis
:
{
itemStyle
:
{
shadowBlur
:
10
,
shadowColor
:
'
rgba(0, 0, 0, 0.5)
'
}
}
}]
};
...
...
@@ -480,10 +474,20 @@ window.allChartsOptions = [
{
series
:
[{
type
:
'
sunburst
'
,
label
:
{
fontSize
:
6
,
color
:
'
#fff
'
},
emphasis
:
{
label
:
{
fontSize
:
12
}
},
radius
:
[
20
,
'
80%
'
],
data
:
[{
name
:
'
Food
'
,
children
:
[{
value
:
5
,
value
:
3
,
name
:
'
Fruit
'
,
children
:
[{
value
:
1
,
...
...
@@ -494,15 +498,13 @@ window.allChartsOptions = [
children
:
[{
name
:
'
Seville Orange
'
,
value
:
1
}]
},
{
children
:
[{
},
{
name
:
'
Blood Orange
'
,
value
:
1
}]
}]
},
{
value
:
10
,
value
:
9
,
name
:
'
Meat
'
,
children
:
[{
value
:
6
,
...
...
@@ -528,17 +530,15 @@ window.allChartsOptions = [
value
:
1
}]
},
{
children
:
[{
name
:
'
Breast
'
,
value
:
1
}]
name
:
'
Breast
'
,
value
:
1
}]
}]
},
{
value
:
9
,
value
:
6
,
name
:
'
Drinks
'
,
children
:
[{
value
:
4
,
value
:
3
,
name
:
'
Wine
'
,
children
:
[{
name
:
'
USA
'
,
...
...
@@ -560,12 +560,12 @@ window.allChartsOptions = [
value
:
1
},
{
name
:
'
Orange Juice
'
,
value
:
1
value
:
2
}]
}]
}]
},
{
value
:
7
,
value
:
6
,
name
:
'
Fashion
'
,
children
:
[{
name
:
'
Clothing
'
,
...
...
@@ -598,7 +598,7 @@ window.allChartsOptions = [
name
:
'
Computers
'
,
children
:
[{
name
:
'
Components
'
,
value
:
6
,
value
:
4
,
children
:
[{
name
:
'
Barebones
'
,
value
:
1
...
...
@@ -639,7 +639,7 @@ window.allChartsOptions = [
data
:
[{
name
:
'
Food
'
,
children
:
[{
value
:
5
,
value
:
3
,
name
:
'
Fruit
'
,
children
:
[{
value
:
1
,
...
...
@@ -650,15 +650,13 @@ window.allChartsOptions = [
children
:
[{
name
:
'
Seville Orange
'
,
value
:
1
}]
},
{
children
:
[{
},
{
name
:
'
Blood Orange
'
,
value
:
1
}]
}]
},
{
value
:
10
,
value
:
8
,
name
:
'
Meat
'
,
children
:
[{
value
:
6
,
...
...
@@ -684,17 +682,15 @@ window.allChartsOptions = [
value
:
1
}]
},
{
children
:
[{
name
:
'
Breast
'
,
value
:
1
}]
name
:
'
Breast
'
,
value
:
1
}]
}]
},
{
value
:
9
,
value
:
6
,
name
:
'
Drinks
'
,
children
:
[{
value
:
4
,
value
:
3
,
name
:
'
Wine
'
,
children
:
[{
name
:
'
USA
'
,
...
...
@@ -716,12 +712,12 @@ window.allChartsOptions = [
value
:
1
},
{
name
:
'
Orange Juice
'
,
value
:
1
value
:
2
}]
}]
}]
},
{
value
:
7
,
value
:
6
,
name
:
'
Fashion
'
,
children
:
[{
name
:
'
Clothing
'
,
...
...
@@ -754,7 +750,7 @@ window.allChartsOptions = [
name
:
'
Computers
'
,
children
:
[{
name
:
'
Components
'
,
value
:
6
,
value
:
4
,
children
:
[{
name
:
'
Barebones
'
,
value
:
1
...
...
@@ -909,12 +905,6 @@ window.allChartsOptions = [
series
:
[
{
type
:
'
themeRiver
'
,
emphasis
:
{
itemStyle
:
{
shadowBlur
:
20
,
shadowColor
:
'
rgba(0, 0, 0, 0.8)
'
}
},
/* eslint-disable */
data
:
[[
'
2015/11/08
'
,
10
,
'
DQ
'
],[
'
2015/11/09
'
,
15
,
'
DQ
'
],[
'
2015/11/10
'
,
35
,
'
DQ
'
],
[
'
2015/11/11
'
,
38
,
'
DQ
'
],[
'
2015/11/12
'
,
22
,
'
DQ
'
],[
'
2015/11/13
'
,
16
,
'
DQ
'
],
...
...
@@ -1124,6 +1114,9 @@ window.allChartsOptions = [
series
:
[{
type
:
'
custom
'
,
dimensions
:
[
'
x
'
,
'
y
'
],
labelLayout
:
{
hideOverlap
:
true
},
renderItem
:
function
(
params
,
api
)
{
var
points
=
[];
for
(
var
i
=
0
;
i
<
data
[
params
.
dataIndex
].
length
;)
{
...
...
@@ -1141,6 +1134,21 @@ window.allChartsOptions = [
shape
:
{
points
:
points
,
},
textContent
:
{
style
:
{
text
:
new
Intl
.
DateTimeFormat
(
'
en-US
'
,
{
year
:
'
2-digit
'
,
month
:
'
2-digit
'
,
day
:
'
2-digit
'
,
hour
:
'
numeric
'
,
minute
:
'
numeric
'
,
second
:
'
numeric
'
}).
format
(
new
Date
(
rawData
[
params
.
dataIndex
].
wall_time
)),
align
:
'
left
'
,
verticalAlign
:
'
bottom
'
},
x
:
points
[
0
][
0
],
y
:
points
[
0
][
1
],
},
textConfig
:
{
position
:
null
},
style
:
api
.
style
({
stroke
:
'
#005
'
,
lineWidth
:
1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录