Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
5b10d82e
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,发现更多精彩内容 >>
提交
5b10d82e
编写于
3月 24, 2021
作者:
O
Ovilia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP(legend): move default legend icon logic from series to legend
上级
dc2282fa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
73 deletion
+61
-73
src/component/legend/LegendView.ts
src/component/legend/LegendView.ts
+47
-25
src/component/legend/seriesLegendIcon.ts
src/component/legend/seriesLegendIcon.ts
+0
-34
src/model/Series.ts
src/model/Series.ts
+14
-14
未找到文件。
src/component/legend/LegendView.ts
浏览文件 @
5b10d82e
...
...
@@ -18,7 +18,9 @@
*/
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
{
createSymbol
}
from
'
../../util/symbol
'
;
import
{
DisplayableState
}
from
'
zrender/src/graphic/Displayable
'
;
import
{
PathStyleProps
}
from
'
zrender/src/graphic/Path
'
;
import
{
parse
,
stringify
}
from
'
zrender/src/tool/color
'
;
import
*
as
graphic
from
'
../../util/graphic
'
;
import
{
enableHoverEmphasis
}
from
'
../../util/states
'
;
import
{
setLabelStyle
,
createTextStyle
}
from
'
../../label/labelStyle
'
;
...
...
@@ -30,27 +32,17 @@ import GlobalModel from '../../model/Global';
import
ExtensionAPI
from
'
../../core/ExtensionAPI
'
;
import
{
ZRTextAlign
,
ZRColor
,
ItemStyleOption
,
ZRRectLike
,
CommonTooltipOption
,
ColorString
,
SeriesOption
,
SymbolOptionMixin
,
LineStyleOption
,
DecalObject
SymbolOptionMixin
}
from
'
../../util/types
'
;
import
Model
from
'
../../model/Model
'
;
import
Displayable
,
{
DisplayableState
}
from
'
zrender/src/graphic/Displayable
'
;
import
{
PathStyleProps
}
from
'
zrender/src/graphic/Path
'
;
import
{
parse
,
stringify
}
from
'
zrender/src/tool/color
'
;
import
{
PatternObject
}
from
'
zrender/src/graphic/Pattern
'
;
import
{
SeriesModel
}
from
'
../../echarts
'
;
import
linesLayout
from
'
../../chart/lines/linesLayout
'
;
import
{
LineStyleProps
,
LINE_STYLE_KEY_MAP
}
from
'
../../model/mixin/lineStyle
'
;
import
{
ItemStyleProps
,
ITEM_STYLE_KEY_MAP
}
from
'
../../model/mixin/itemStyle
'
;
import
{
number
}
from
'
../../export/api
'
;
import
makeStyleMapper
from
'
../../model/mixin/makeStyleMapper
'
;
import
{
ITEM_STYLE_KEY_MAP
}
from
'
../../model/mixin/itemStyle
'
;
import
{
createSymbol
,
ECSymbol
}
from
'
../../util/symbol
'
;
const
curry
=
zrUtil
.
curry
;
const
each
=
zrUtil
.
each
;
...
...
@@ -393,17 +385,18 @@ class LegendView extends ComponentView {
const
textStyleModel
=
itemModel
.
getModel
(
'
textStyle
'
);
itemGroup
.
add
(
seriesModel
.
getLegendIcon
({
series
:
seriesModel
,
itemWidth
,
itemHeight
,
symbolType
:
dataSymbolType
||
'
roundRect
'
,
symbolKeepAspect
,
itemStyle
:
style
.
itemStyle
,
lineStyle
:
style
.
lineStyle
})
)
const
getLegendIcon
=
typeof
seriesModel
.
getLegendIcon
===
'
function
'
?
seriesModel
.
getLegendIcon
:
getDefaultLegendIcon
;
itemGroup
.
add
(
getLegendIcon
({
series
:
seriesModel
,
itemWidth
,
itemHeight
,
symbolType
:
dataSymbolType
||
'
roundRect
'
,
symbolKeepAspect
,
itemStyle
:
style
.
itemStyle
,
lineStyle
:
style
.
lineStyle
}));
const
textX
=
itemAlign
===
'
left
'
?
itemWidth
+
5
:
-
5
;
const
textAlign
=
itemAlign
as
ZRTextAlign
;
...
...
@@ -637,6 +630,35 @@ function getLegendStyle(
return
{
itemStyle
,
lineStyle
};
}
function
getDefaultLegendIcon
(
opt
:
{
series
:
SeriesModel
,
itemWidth
:
number
,
itemHeight
:
number
,
symbolType
:
string
,
symbolKeepAspect
:
boolean
,
itemStyle
:
PathStyleProps
,
lineStyle
:
LineStyleProps
}):
ECSymbol
{
const
symbol
=
createSymbol
(
opt
.
symbolType
,
0
,
0
,
opt
.
itemWidth
,
opt
.
itemHeight
,
opt
.
itemStyle
.
fill
,
opt
.
symbolKeepAspect
);
symbol
.
setStyle
(
opt
.
itemStyle
);
if
(
opt
.
symbolType
.
indexOf
(
'
empty
'
)
>
-
1
)
{
symbol
.
style
.
stroke
=
symbol
.
style
.
fill
;
symbol
.
style
.
fill
=
'
#fff
'
;
}
return
symbol
;
}
function
dispatchSelectAction
(
seriesName
:
string
,
dataName
:
string
,
...
...
src/component/legend/seriesLegendIcon.ts
已删除
100644 → 0
浏览文件 @
dc2282fa
import
{
PathStyleProps
}
from
'
zrender/src/graphic/Path
'
;
import
{
SeriesModel
}
from
'
../../export/api
'
;
import
{
LineStyleProps
}
from
'
../../model/mixin/lineStyle
'
;
import
{
Group
}
from
'
../../util/graphic
'
;
import
{
createSymbol
,
ECSymbol
}
from
'
../../util/symbol
'
;
export
function
defaultSeriesLegendIcon
(
opt
:
{
series
:
SeriesModel
,
itemWidth
:
number
,
itemHeight
:
number
,
symbolType
:
string
,
symbolKeepAspect
:
boolean
,
itemStyle
:
PathStyleProps
,
lineStyle
:
LineStyleProps
}):
ECSymbol
|
Group
{
const
symbol
=
createSymbol
(
opt
.
symbolType
,
0
,
0
,
opt
.
itemWidth
,
opt
.
itemHeight
,
opt
.
itemStyle
.
fill
,
opt
.
symbolKeepAspect
);
symbol
.
setStyle
(
opt
.
itemStyle
);
if
(
opt
.
symbolType
.
indexOf
(
'
empty
'
)
>
-
1
)
{
symbol
.
style
.
stroke
=
symbol
.
style
.
fill
;
symbol
.
style
.
fill
=
'
#fff
'
;
}
return
symbol
;
}
src/model/Series.ts
浏览文件 @
5b10d82e
...
...
@@ -20,6 +20,7 @@
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
env
from
'
zrender/src/core/env
'
;
import
type
{
MorphDividingMethod
}
from
'
zrender/src/tool/morphPath
'
;
import
{
PathStyleProps
}
from
'
zrender/src/graphic/Path
'
;
import
*
as
modelUtil
from
'
../util/model
'
;
import
{
DataHost
,
DimensionName
,
StageHandlerProgressParams
,
...
...
@@ -50,8 +51,6 @@ import { Source } from '../data/Source';
import
{
defaultSeriesFormatTooltip
}
from
'
../component/tooltip/seriesFormatTooltip
'
;
import
{
ECSymbol
}
from
'
../util/symbol
'
;
import
{
Group
}
from
'
../util/graphic
'
;
import
{
defaultSeriesLegendIcon
}
from
'
../component/legend/seriesLegendIcon
'
;
import
{
PathStyleProps
}
from
'
zrender/src/graphic/Path
'
;
import
{
LineStyleProps
}
from
'
./mixin/lineStyle
'
;
const
inner
=
modelUtil
.
makeInner
<
{
...
...
@@ -95,6 +94,19 @@ interface SeriesModel {
*/
getMarkerPosition
(
value
:
ScaleDataValue
[]):
number
[];
/**
* Get legend icon symbol according to each series type
*/
getLegendIcon
(
opt
:
{
series
:
SeriesModel
,
itemWidth
:
number
,
itemHeight
:
number
,
symbolType
:
string
,
symbolKeepAspect
:
boolean
,
itemStyle
:
PathStyleProps
,
lineStyle
:
LineStyleProps
}):
ECSymbol
|
Group
;
/**
* See `component/brush/selector.js`
* Defined the brush selector for this series.
...
...
@@ -438,18 +450,6 @@ class SeriesModel<Opt extends SeriesOption = SeriesOption> extends ComponentMode
});
}
getLegendIcon
(
opt
:
{
series
:
SeriesModel
,
itemWidth
:
number
,
itemHeight
:
number
,
symbolType
:
string
,
symbolKeepAspect
:
boolean
,
itemStyle
:
PathStyleProps
,
lineStyle
:
LineStyleProps
}):
ECSymbol
|
Group
{
return
defaultSeriesLegendIcon
(
opt
);
}
isAnimationEnabled
():
boolean
{
if
(
env
.
node
)
{
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录