Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
aa7f802f
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,发现更多精彩内容 >>
提交
aa7f802f
编写于
3月 17, 2021
作者:
O
Ovilia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP(legend): fix symbolSize
上级
635d986b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
30 deletion
+33
-30
src/component/legend/LegendModel.ts
src/component/legend/LegendModel.ts
+2
-2
src/component/legend/LegendView.ts
src/component/legend/LegendView.ts
+31
-28
未找到文件。
src/component/legend/LegendModel.ts
浏览文件 @
aa7f802f
...
...
@@ -72,7 +72,7 @@ export interface LegendItemStyleOption {
shadowOffsetX
?:
number
|
'
inherit
'
shadowOffsetY
?:
number
|
'
inherit
'
borderColor
?:
ZRColor
|
'
inherit
'
borderWidth
?:
number
|
'
inherit
'
borderWidth
?:
number
|
'
inherit
'
|
'
auto
'
borderType
?:
ZRLineType
|
'
inherit
'
borderCap
?:
CanvasLineCap
|
'
inherit
'
borderJoin
?:
CanvasLineJoin
|
'
inherit
'
...
...
@@ -468,7 +468,7 @@ class LegendModel<Ops extends LegendOption = LegendOption> extends ComponentMode
shadowOffsetX
:
'
inherit
'
,
shadowOffsetY
:
'
inherit
'
,
borderColor
:
'
inherit
'
,
borderWidth
:
'
inherit
'
,
borderWidth
:
'
auto
'
,
borderCap
:
'
inherit
'
,
borderJoin
:
'
inherit
'
,
borderDashOffset
:
'
inherit
'
,
...
...
src/component/legend/LegendView.ts
浏览文件 @
aa7f802f
...
...
@@ -336,66 +336,62 @@ class LegendView extends ComponentView {
itemModel
:
LegendModel
[
'
_data
'
][
number
],
legendModel
:
LegendModel
,
legendSymbolType
:
string
,
s
ymbolType
:
string
,
s
ymbolSize
:
number
|
number
[],
dataS
ymbolType
:
string
,
dataS
ymbolSize
:
number
|
number
[],
itemAlign
:
LegendOption
[
'
align
'
],
lineVisualStyle
:
LineStyleProps
,
itemVisualStyle
:
PathStyleProps
,
isColorBySeries
:
boolean
,
selectMode
:
LegendOption
[
'
selectedMode
'
]
)
{
if
(
symbolSize
!=
null
&&
typeof
symbolSize
===
'
object
'
)
{
// Use symbol height as symbol size if it's an array
symbolSize
=
symbolSize
[
1
];
}
const
itemWidth
=
legendModel
.
get
(
'
itemWidth
'
);
const
itemHeight
=
legendModel
.
get
(
'
itemHeight
'
);
const
isSelected
=
legendModel
.
isSelected
(
name
);
const
symbolKeepAspect
=
itemModel
.
get
(
'
symbolKeepAspect
'
);
const
itemIcon
=
itemModel
.
get
(
'
icon
'
);
let
symbolSize
;
const
legendSymbolSize
=
itemModel
.
get
(
'
symbolSize
'
);
if
(
legendSymbolSize
===
'
auto
'
)
{
// auto: 80% itemHeight
symbolSize
=
itemHeight
*
0.8
;
// auto: 80% itemHeight if has line, 100% elsewise
const
hasHorizontalLine
=
!
itemIcon
&&
dataSymbolType
&&
((
dataSymbolType
!==
legendSymbolType
)
||
dataSymbolType
===
'
none
'
);
symbolSize
=
hasHorizontalLine
?
itemHeight
*
0.8
:
[
itemWidth
,
itemHeight
];
}
else
if
(
legendSymbolSize
!==
'
inherit
'
)
{
else
if
(
legendSymbolSize
!==
'
inherit
'
)
{
// number: legend.symbolSize
symbolSize
=
Math
.
min
(
legendSymbolSize
,
itemHeight
);
symbolSize
=
legendSymbolSize
;
}
else
{
// inherit: series.symbolSize
symbolSize
=
dataSymbolSize
;
}
// inherit: series.symbolSize, which is passed in by function parameter
const
legendLineStyle
=
legendModel
.
getModel
(
'
lineStyle
'
);
const
style
=
getLegendStyle
(
itemModel
,
legendLineStyle
,
lineVisualStyle
,
itemVisualStyle
,
isColorBySeries
,
isSelected
);
symbolType
=
s
ymbolType
||
'
roundRect
'
;
dataSymbolType
=
dataS
ymbolType
||
'
roundRect
'
;
const
itemGroup
=
new
Group
();
const
textStyleModel
=
itemModel
.
getModel
(
'
textStyle
'
);
const
itemIcon
=
itemModel
.
get
(
'
icon
'
);
// Use user given icon first
legendSymbolType
=
itemIcon
||
legendSymbolType
;
const
hasHorizontalLine
=
!
itemIcon
&&
symbolType
// At least show one symbol, can't be all none
&&
((
symbolType
!==
legendSymbolType
)
||
symbolType
===
'
none
'
);
// Draw line
if
(
legendSymbolType
===
'
line
'
||
itemIcon
===
'
line
'
)
{
itemGroup
.
add
(
createHorizontalLine
(
itemWidth
,
itemHeight
,
style
.
lineStyle
)
)
}
// Put symbol in the center
if
(
itemIcon
!==
'
line
'
)
{
itemGroup
.
add
(
createItem
(
s
ymbolType
,
symbolSize
,
symbolKeepAspect
,
itemWidth
,
itemHeight
,
style
.
itemStyle
)
createItem
(
dataS
ymbolType
,
symbolSize
,
symbolKeepAspect
,
itemWidth
,
itemHeight
,
style
.
itemStyle
)
);
}
...
...
@@ -579,6 +575,10 @@ function getLegendStyle(
if
(
value
===
'
inherit
'
)
{
(
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
?
2
:
0
;
}
else
{
(
itemStyle
as
any
)[
visualName
]
=
value
;
}
...
...
@@ -652,14 +652,17 @@ function createItem(
symbolType
=
'
circle
'
;
}
const
size
=
symbolSize
==
null
?
itemHeight
:
Math
.
min
(
itemHeight
,
symbolSize
as
number
);
?
[
itemHeight
,
itemHeight
]
:
(
typeof
symbolSize
===
'
object
'
?
[
Math
.
min
(
itemWidth
,
symbolSize
[
0
]),
Math
.
min
(
itemHeight
,
symbolSize
[
1
])]
:
[
Math
.
min
(
itemHeight
,
symbolSize
as
number
),
Math
.
min
(
itemHeight
,
symbolSize
as
number
)]
);
const
symbol
=
createSymbol
(
symbolType
,
(
itemWidth
-
size
)
/
2
,
(
itemHeight
-
size
)
/
2
,
size
,
size
,
(
itemWidth
-
size
[
0
]
)
/
2
,
(
itemHeight
-
size
[
1
]
)
/
2
,
size
[
0
]
,
size
[
1
]
,
style
.
fill
,
// symbolKeepAspect default true for legend
symbolKeepAspect
==
null
?
true
:
symbolKeepAspect
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录