Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
36462969
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,发现更多精彩内容 >>
提交
36462969
编写于
3月 17, 2021
作者:
O
Ovilia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP(legend): style when series is not selected
上级
7955fd89
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
16 deletion
+23
-16
src/chart/line/install.ts
src/chart/line/install.ts
+1
-5
src/component/legend/LegendModel.ts
src/component/legend/LegendModel.ts
+4
-0
src/component/legend/LegendView.ts
src/component/legend/LegendView.ts
+16
-9
src/data/List.ts
src/data/List.ts
+2
-2
未找到文件。
src/chart/line/install.ts
浏览文件 @
36462969
...
...
@@ -42,15 +42,11 @@ export function install(registers: EChartsExtensionInstallRegisters) {
const
lineStyle
=
seriesModel
.
getModel
(
'
lineStyle
'
).
getLineStyle
();
const
itemStyle
=
seriesModel
.
getModel
(
'
itemStyle
'
).
getItemStyle
();
const
color
=
itemStyle
&&
itemStyle
.
fill
;
console
.
log
(
itemStyle
,
lineStyle
);
if
(
lineStyle
)
{
lineStyle
.
stroke
=
lineStyle
.
stroke
||
color
;
}
seriesModel
.
getData
().
setVisual
(
'
legendSymbolStyle
'
,
{
itemStyle
,
lineStyle
});
seriesModel
.
getData
().
setVisual
(
'
legendLineStyle
'
,
lineStyle
);
}
});
...
...
src/component/legend/LegendModel.ts
浏览文件 @
36462969
...
...
@@ -93,6 +93,8 @@ export interface LegendLineStyleOption {
shadowColor
?:
ColorString
|
'
inherit
'
shadowOffsetX
?:
number
|
'
inherit
'
shadowOffsetY
?:
number
|
'
inherit
'
inactiveColor
?:
ColorString
,
inactiveWidth
?:
number
}
export
interface
LegendStyleOption
{
...
...
@@ -476,6 +478,8 @@ class LegendModel<Ops extends LegendOption = LegendOption> extends ComponentMode
lineStyle
:
{
width
:
'
auto
'
,
color
:
'
inherit
'
,
inactiveColor
:
'
#ccc
'
,
inactiveWidth
:
2
,
opacity
:
'
inherit
'
,
type
:
'
inherit
'
,
cap
:
'
inherit
'
,
...
...
src/component/legend/LegendView.ts
浏览文件 @
36462969
...
...
@@ -25,7 +25,7 @@ import {setLabelStyle, createTextStyle} from '../../label/labelStyle';
import
{
makeBackground
}
from
'
../helper/listComponent
'
;
import
*
as
layoutUtil
from
'
../../util/layout
'
;
import
ComponentView
from
'
../../view/Component
'
;
import
LegendModel
,
{
LegendItemStyleOption
,
LegendLineStyleOption
,
LegendOption
,
LegendSelectorButtonOption
,
Legend
StyleOption
,
LegendSymbolStyleOption
,
Legend
TooltipFormatterParams
}
from
'
./LegendModel
'
;
import
LegendModel
,
{
LegendItemStyleOption
,
LegendLineStyleOption
,
LegendOption
,
LegendSelectorButtonOption
,
LegendTooltipFormatterParams
}
from
'
./LegendModel
'
;
import
GlobalModel
from
'
../../model/Global
'
;
import
ExtensionAPI
from
'
../../core/ExtensionAPI
'
;
import
{
...
...
@@ -208,14 +208,13 @@ class LegendView extends ComponentView {
// Legend to control series.
if
(
seriesModel
)
{
const
data
=
seriesModel
.
getData
();
const
lineVisualStyle
=
(
data
.
getVisual
(
'
legendSymbolStyle
'
)
||
{}).
lineStyle
;
const
lineVisualStyle
=
data
.
getVisual
(
'
legendLineStyle
'
)
||
{}
;
/**
* `data.getVisual('style')` may be the color from the register
* in series. For example, for line series,
*/
const
style
=
data
.
getVisual
(
'
style
'
);
console
.
log
(
style
,
lineVisualStyle
);
// Using rect symbol defaultly
const
legendSymbolType
=
data
.
getVisual
(
'
legendSymbol
'
)
||
'
roundRect
'
;
...
...
@@ -223,7 +222,6 @@ class LegendView extends ComponentView {
const
symbolSize
=
data
.
getVisual
(
'
symbolSize
'
);
data
.
getVisual
(
'
symbolSize
'
);
console
.
log
(
symbolSize
)
const
itemGroup
=
this
.
_createItem
(
name
,
dataIndex
,
legendItemModel
,
legendModel
,
...
...
@@ -356,14 +354,12 @@ class LegendView extends ComponentView {
const
itemHeight
=
legendModel
.
get
(
'
itemHeight
'
);
const
isSelected
=
legendModel
.
isSelected
(
name
);
const
inactiveColor
=
itemModel
.
get
(
'
inactiveColor
'
);
const
inactiveBorderColor
=
itemModel
.
get
(
'
inactiveBorderColor
'
);
const
symbolKeepAspect
=
itemModel
.
get
(
'
symbolKeepAspect
'
);
const
legendSymbolSize
=
itemModel
.
get
(
'
symbolSize
'
);
if
(
legendSymbolSize
===
'
auto
'
)
{
// auto: 80% itemHeight
symbolSize
=
itemHeight
*
0.8
;
symbolSize
=
itemHeight
*
0.8
;
}
else
if
(
legendSymbolSize
!==
'
inherit
'
)
{
// number: legend.symbolSize
...
...
@@ -371,7 +367,8 @@ class LegendView extends ComponentView {
}
// inherit: series.symbolSize, which is passed in by function parameter
const
style
=
getLegendStyle
(
itemModel
,
lineVisualStyle
,
itemVisualStyle
,
isColorBySeries
);
const
legendLineStyle
=
legendModel
.
getModel
(
'
lineStyle
'
);
const
style
=
getLegendStyle
(
itemModel
,
legendLineStyle
,
lineVisualStyle
,
itemVisualStyle
,
isColorBySeries
,
isSelected
);
symbolType
=
symbolType
||
'
roundRect
'
;
...
...
@@ -417,6 +414,7 @@ class LegendView extends ComponentView {
content
=
formatter
(
name
);
}
const
inactiveColor
=
itemModel
.
get
(
'
inactiveColor
'
);
itemGroup
.
add
(
new
graphic
.
Text
({
style
:
createTextStyle
(
textStyleModel
,
{
text
:
content
,
...
...
@@ -551,9 +549,11 @@ class LegendView extends ComponentView {
function
getLegendStyle
(
legendModel
:
LegendModel
[
'
_data
'
][
number
],
legendLineStyle
:
Model
<
LegendLineStyleOption
>
,
lineVisualStyle
:
LineStyleProps
,
itemVisualStyle
:
PathStyleProps
,
isColorBySeries
:
boolean
isColorBySeries
:
boolean
,
isSelected
:
boolean
)
{
let
color
=
itemVisualStyle
.
fill
;
if
(
!
isColorBySeries
)
{
...
...
@@ -622,6 +622,13 @@ function getLegendStyle(
(
itemStyle
.
stroke
===
'
auto
'
)
&&
(
itemStyle
.
stroke
=
color
);
(
lineStyle
.
stroke
===
'
auto
'
)
&&
(
lineStyle
.
stroke
=
color
);
if
(
!
isSelected
)
{
itemStyle
.
fill
=
legendModel
.
get
(
'
inactiveColor
'
);
itemStyle
.
stroke
=
legendModel
.
get
(
'
inactiveBorderColor
'
);
lineStyle
.
stroke
=
legendLineStyle
.
get
(
'
inactiveColor
'
);
lineStyle
.
lineWidth
=
legendLineStyle
.
get
(
'
inactiveWidth
'
);
}
return
{
itemStyle
,
lineStyle
};
}
...
...
src/data/List.ts
浏览文件 @
36462969
...
...
@@ -46,7 +46,7 @@ import type { VisualMeta } from '../component/visualMap/VisualMapModel';
import
{
parseDataValue
}
from
'
./helper/dataValueHelper
'
;
import
{
isSourceInstance
,
Source
}
from
'
./Source
'
;
import
OrdinalMeta
from
'
./OrdinalMeta
'
;
import
{
L
egendSymbolStyleOption
}
from
'
./../component/legend/LegendModel
'
;
import
{
L
ineStyleProps
}
from
'
../model/mixin/lineStyle
'
;
const
mathFloor
=
Math
.
floor
;
const
isObject
=
zrUtil
.
isObject
;
...
...
@@ -141,7 +141,7 @@ export interface DefaultDataVisual {
liftZ
?:
number
// For legend.
legendSymbol
?:
string
legend
SymbolStyle
?:
LegendSymbolStyleOption
legend
LineStyle
?:
LineStyleProps
// visualMap will inject visualMeta data
visualMeta
?:
VisualMeta
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录