Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
e95638a3
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,发现更多精彩内容 >>
提交
e95638a3
编写于
3月 22, 2021
作者:
O
Ovilia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP(legend): add more style attributes
上级
ef532ba3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
57 addition
and
13 deletion
+57
-13
src/component/legend/LegendView.ts
src/component/legend/LegendView.ts
+57
-13
未找到文件。
src/component/legend/LegendView.ts
浏览文件 @
e95638a3
...
...
@@ -220,13 +220,15 @@ class LegendView extends ComponentView {
const
symbolType
=
data
.
getVisual
(
'
symbol
'
);
const
symbolSize
=
data
.
getVisual
(
'
symbolSize
'
);
const
drawType
=
seriesModel
.
visualDrawType
;
data
.
getVisual
(
'
symbolSize
'
);
const
itemGroup
=
this
.
_createItem
(
name
,
dataIndex
,
legendItemModel
,
legendModel
,
legendSymbolType
,
symbolType
,
symbolSize
,
itemAlign
,
lineVisualStyle
,
style
,
selectMode
lineVisualStyle
,
style
,
drawType
,
selectMode
);
itemGroup
.
on
(
'
click
'
,
curry
(
dispatchSelectAction
,
name
,
null
,
api
,
excludeSeriesId
))
...
...
@@ -264,12 +266,13 @@ class LegendView extends ComponentView {
}
const
legendSymbolType
=
'
roundRect
'
;
const
drawType
=
seriesModel
.
visualDrawType
;
const
itemGroup
=
this
.
_createItem
(
name
,
dataIndex
,
legendItemModel
,
legendModel
,
legendSymbolType
,
null
,
null
,
itemAlign
,
{},
style
,
selectMode
{},
style
,
drawType
,
selectMode
);
// FIXME: consider different series has items with the same name.
...
...
@@ -351,6 +354,7 @@ class LegendView extends ComponentView {
itemAlign
:
LegendOption
[
'
align
'
],
lineVisualStyle
:
LineStyleProps
,
itemVisualStyle
:
PathStyleProps
,
drawType
:
'
fill
'
|
'
stroke
'
,
selectMode
:
LegendOption
[
'
selectedMode
'
]
)
{
const
itemWidth
=
legendModel
.
get
(
'
itemWidth
'
);
...
...
@@ -379,11 +383,11 @@ class LegendView extends ComponentView {
symbolSize
=
dataSymbolSize
;
}
const
legendLineStyle
=
legendModel
.
getModel
(
'
lineStyle
'
);
const
style
=
getLegendStyle
(
itemModel
,
legendLineStyle
,
lineVisualStyle
,
itemVisualStyle
,
isSelected
);
dataSymbolType
=
dataSymbolType
||
'
roundRect
'
;
const
legendLineStyle
=
legendModel
.
getModel
(
'
lineStyle
'
);
const
style
=
getLegendStyle
(
dataSymbolType
,
itemModel
,
legendLineStyle
,
lineVisualStyle
,
itemVisualStyle
,
drawType
,
isSelected
);
const
itemGroup
=
new
Group
();
const
textStyleModel
=
itemModel
.
getModel
(
'
textStyle
'
);
...
...
@@ -542,10 +546,12 @@ class LegendView extends ComponentView {
}
function
getLegendStyle
(
symbolType
:
string
,
legendModel
:
LegendModel
[
'
_data
'
][
number
],
legendLineStyle
:
Model
<
LegendLineStyleOption
>
,
lineVisualStyle
:
LineStyleProps
,
itemVisualStyle
:
PathStyleProps
,
drawType
:
'
fill
'
|
'
stroke
'
,
isSelected
:
boolean
)
{
/**
...
...
@@ -557,22 +563,41 @@ function getLegendStyle(
const
legendItemModel
=
legendModel
.
getModel
(
'
itemStyle
'
)
as
Model
<
LegendItemStyleOption
>
;
const
itemProperties
=
[
[
'
fill
'
,
'
color
'
],
[
'
lineWidth
'
,
'
borderWidth
'
],
[
'
opacity
'
],
[
'
decal
'
],
[
'
shadowBlur
'
],
[
'
shadowColor
'
],
[
'
shadowOffsetX
'
],
[
'
shadowOffsetY
'
],
[
'
stroke
'
,
'
borderColor
'
],
[
'
width
'
,
'
width
'
],
[
'
opacity
'
,
'
opacity
'
]
[
'
lineWidth
'
,
'
borderWidth
'
],
[
'
borderCap
'
],
[
'
borderJoin
'
],
[
'
borderDashOffset
'
],
[
'
borderMiterLimit
'
]
];
const
itemStyle
:
PathStyleProps
=
{};
for
(
let
i
=
0
;
i
<
itemProperties
.
length
;
++
i
)
{
const
propName
=
itemProperties
[
i
][
1
]
as
keyof
LegendItemStyleOption
;
const
propName
=
itemProperties
[
i
][
itemProperties
[
i
].
length
-
1
]
as
keyof
LegendItemStyleOption
;
const
visualName
=
itemProperties
[
i
][
0
]
as
keyof
PathStyleProps
;
const
value
=
legendItemModel
.
getShallow
(
propName
)
as
LegendItemStyleOption
[
keyof
LegendItemStyleOption
];
if
(
value
===
'
inherit
'
)
{
(
itemStyle
as
any
)[
visualName
]
=
itemVisualStyle
[
visualName
];
if
(
drawType
===
'
stroke
'
&&
visualName
===
'
fill
'
)
{
/**
* Series with visualDrawType as 'stroke' should have
* series stroke as legend fill
*/
itemStyle
.
fill
=
itemVisualStyle
.
stroke
;
}
else
{
(
itemStyle
as
any
)[
visualName
]
=
itemVisualStyle
[
visualName
];
}
}
else
if
(
value
===
'
auto
'
&&
visualName
===
'
lineWidth
'
)
{
// If lineStyle.width is 'auto', it is set to be 2 if series has border
itemStyle
.
lineWidth
=
(
itemVisualStyle
.
lineWidth
>
0
&&
itemVisualStyle
.
stroke
)
?
2
:
0
;
itemStyle
.
lineWidth
=
(
itemVisualStyle
.
lineWidth
>
0
)
?
2
:
0
;
}
else
{
(
itemStyle
as
any
)[
visualName
]
=
value
;
...
...
@@ -582,8 +607,21 @@ function getLegendStyle(
// lineStyle
const
legendLineModel
=
legendModel
.
getModel
(
'
lineStyle
'
)
as
Model
<
LegendLineStyleOption
>
;
const
lineProperties
=
[
[
'
lineWidth
'
,
'
width
'
],
[
'
stroke
'
,
'
color
'
],
[
'
lineWidth
'
,
'
width
'
]
[
'
inactiveColor
'
],
[
'
inactiveWidth
'
],
[
'
opacity
'
],
[
'
type
'
],
[
'
cap
'
],
[
'
join
'
],
[
'
dashOffset
'
],
[
'
miterLimit
'
],
[
'
shadowB
'
],
[
'
shadowBlur
'
],
[
'
shadowColor
'
],
[
'
shadowOffsetX
'
],
[
'
shadowOffsetY
'
]
];
const
lineStyle
:
LineStyleProps
=
{};
for
(
let
i
=
0
;
i
<
lineProperties
.
length
;
++
i
)
{
...
...
@@ -609,8 +647,14 @@ function getLegendStyle(
if
(
!
isSelected
)
{
const
borderWidth
=
legendModel
.
get
(
'
inactiveBorderWidth
'
);
/**
* Since stroke is set to be inactiveBorderColor, it may occur that
* there is no border in series but border in legend, so we need to
* use border only when series has border if is set to be auto
*/
const
visualHasBorder
=
itemStyle
[
symbolType
.
indexOf
(
'
empty
'
)
>
-
1
?
'
fill
'
:
'
stroke
'
];
itemStyle
.
lineWidth
=
borderWidth
===
'
auto
'
?
(
itemVisualStyle
.
lineWidth
>
0
&&
itemStyle
.
stroke
?
2
:
0
)
?
(
itemVisualStyle
.
lineWidth
>
0
&&
visualHasBorder
?
2
:
0
)
:
itemStyle
.
lineWidth
;
itemStyle
.
fill
=
legendModel
.
get
(
'
inactiveColor
'
);
itemStyle
.
stroke
=
legendModel
.
get
(
'
inactiveBorderColor
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录