Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
84ce59fc
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,体验更适合开发者的 AI 搜索 >>
提交
84ce59fc
编写于
9月 04, 2020
作者:
O
Ovilia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP(line): line label animation
上级
f680d16e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
108 addition
and
10 deletion
+108
-10
src/chart/helper/createClipPathFromCoordSys.ts
src/chart/helper/createClipPathFromCoordSys.ts
+16
-4
src/chart/line/LineSeries.ts
src/chart/line/LineSeries.ts
+3
-2
src/chart/line/LineView.ts
src/chart/line/LineView.ts
+88
-4
src/label/labelStyle.ts
src/label/labelStyle.ts
+1
-0
未找到文件。
src/chart/helper/createClipPathFromCoordSys.ts
浏览文件 @
84ce59fc
...
...
@@ -31,7 +31,9 @@ type SeriesModelWithLineWidth = SeriesModel<SeriesOption & {
function
createGridClipPath
(
cartesian
:
Cartesian2D
,
hasAnimation
:
boolean
,
seriesModel
:
SeriesModelWithLineWidth
seriesModel
:
SeriesModelWithLineWidth
,
done
?:
()
=>
void
,
during
?:
(
percent
:
number
,
clipRect
:
graphic
.
Rect
)
=>
void
)
{
const
rect
=
cartesian
.
getArea
();
...
...
@@ -69,13 +71,20 @@ function createGridClipPath(
clipPath
.
shape
.
y
=
y
+
height
;
clipPath
.
shape
.
height
=
0
;
}
const
duringCb
=
typeof
during
===
'
function
'
?
(
percent
:
number
)
=>
{
during
(
percent
,
clipPath
);
}
:
null
;
graphic
.
initProps
(
clipPath
,
{
shape
:
{
width
:
width
,
height
:
height
,
y
:
y
}
},
seriesModel
);
},
seriesModel
,
null
,
done
,
duringCb
);
}
return
clipPath
;
...
...
@@ -112,6 +121,7 @@ function createPolarClipPath(
else
{
clipPath
.
shape
.
r
=
r0
;
}
graphic
.
initProps
(
clipPath
,
{
shape
:
{
endAngle
:
sectorArea
.
endAngle
,
...
...
@@ -125,7 +135,9 @@ function createPolarClipPath(
function
createClipPath
(
coordSys
:
CoordinateSystem
,
hasAnimation
:
boolean
,
seriesModel
:
SeriesModelWithLineWidth
seriesModel
:
SeriesModelWithLineWidth
,
done
?:
()
=>
void
,
during
?:
(
percent
:
number
)
=>
void
)
{
if
(
!
coordSys
)
{
return
null
;
...
...
@@ -134,7 +146,7 @@ function createClipPath(
return
createPolarClipPath
(
coordSys
as
Polar
,
hasAnimation
,
seriesModel
);
}
else
if
(
coordSys
.
type
===
'
cartesian2d
'
)
{
return
createGridClipPath
(
coordSys
as
Cartesian2D
,
hasAnimation
,
seriesModel
);
return
createGridClipPath
(
coordSys
as
Cartesian2D
,
hasAnimation
,
seriesModel
,
done
,
during
);
}
return
null
;
}
...
...
src/chart/line/LineSeries.ts
浏览文件 @
84ce59fc
...
...
@@ -82,7 +82,7 @@ export interface LineSeriesOption extends SeriesOption<LineStateOption, ExtraSta
// If clip the overflow value
clip
?:
boolean
label
?:
LabelOption
label
?:
LabelOption
&
{
showDuringLabel
:
boolean
}
lineStyle
?:
LineStyleOption
...
...
@@ -138,7 +138,8 @@ class LineSeriesModel extends SeriesModel<LineSeriesOption> {
clip
:
true
,
label
:
{
position
:
'
top
'
position
:
'
top
'
,
showDuringLabel
:
false
},
lineStyle
:
{
...
...
src/chart/line/LineView.ts
浏览文件 @
84ce59fc
...
...
@@ -37,14 +37,19 @@ import type ExtensionAPI from '../../ExtensionAPI';
import
Cartesian2D
from
'
../../coord/cartesian/Cartesian2D
'
;
import
Polar
from
'
../../coord/polar/Polar
'
;
import
type
List
from
'
../../data/List
'
;
import
type
{
Payload
,
Dictionary
,
ColorString
,
ECElement
,
DisplayState
}
from
'
../../util/types
'
;
import
type
{
Payload
,
Dictionary
,
ColorString
,
ECElement
,
DisplayState
,
ComponentOption
}
from
'
../../util/types
'
;
import
type
OrdinalScale
from
'
../../scale/Ordinal
'
;
import
type
Axis2D
from
'
../../coord/cartesian/Axis2D
'
;
import
{
CoordinateSystemClipArea
}
from
'
../../coord/CoordinateSystem
'
;
import
{
setStatesStylesFromModel
,
setStatesFlag
,
enableHoverEmphasis
}
from
'
../../util/states
'
;
import
{
getECData
}
from
'
../../util/ecData
'
;
import
Displayable
from
'
zrender/src/graphic/Displayable
'
;
import
{
makeInner
}
from
'
../../util/model
'
;
import
ComponentModel
from
'
../../model/Component
'
;
const
inner
=
makeInner
<
{
defaultOption
:
ComponentOption
},
graphic
.
Text
>
();
type
PolarArea
=
ReturnType
<
Polar
[
'
getArea
'
]
>
;
type
Cartesian2DArea
=
ReturnType
<
Cartesian2D
[
'
getArea
'
]
>
;
...
...
@@ -326,13 +331,29 @@ function canShowAllSymbolForCategory(
}
function
createLineClipPath
(
lineView
:
LineView
,
coordSys
:
Cartesian2D
|
Polar
,
hasAnimation
:
boolean
,
seriesModel
:
LineSeriesModel
)
{
if
(
coordSys
.
type
===
'
cartesian2d
'
)
{
const
labelModel
=
seriesModel
.
getModel
(
'
label
'
);
let
showDuringLabel
=
labelModel
.
get
(
'
showDuringLabel
'
);
const
done
=
showDuringLabel
?
()
=>
{
}
:
null
;
const
during
=
showDuringLabel
?
(
percent
:
number
,
clipRect
:
graphic
.
Rect
)
=>
{
lineView
.
_updateDuringLabel
(
percent
,
clipRect
,
lineView
.
_data
);
}
:
null
;
const
isHorizontal
=
coordSys
.
getBaseAxis
().
isHorizontal
();
const
clipPath
=
createGridClipPath
(
coordSys
,
hasAnimation
,
seriesModel
);
const
clipPath
=
createGridClipPath
(
coordSys
,
hasAnimation
,
seriesModel
,
done
,
during
);
// Expand clip shape to avoid clipping when line value exceeds axis
if
(
!
seriesModel
.
get
(
'
clip
'
,
true
))
{
const
rectShape
=
clipPath
.
shape
;
...
...
@@ -349,6 +370,8 @@ function createLineClipPath(
return
clipPath
;
}
else
{
const
labelModel
=
seriesModel
.
getModel
(
'
label
'
);
const
showDuringLabel
=
labelModel
.
get
(
'
showDuringLabel
'
);
return
createPolarClipPath
(
coordSys
,
hasAnimation
,
seriesModel
);
}
...
...
@@ -363,6 +386,8 @@ class LineView extends ChartView {
_lineGroup
:
graphic
.
Group
;
_coordSys
:
Cartesian2D
|
Polar
;
_duringLabel
:
graphic
.
Text
;
_polyline
:
ECPolyline
;
_polygon
:
ECPolygon
;
...
...
@@ -468,6 +493,8 @@ class LineView extends ChartView {
clipShapeForSymbol
);
this
.
_initDuringLabel
(
seriesModel
,
data
,
true
);
if
(
step
)
{
// TODO If stacked series is not step
points
=
turnPointsIntoStep
(
points
,
coordSys
,
step
);
...
...
@@ -480,7 +507,9 @@ class LineView extends ChartView {
points
,
stackedOnPoints
);
}
lineGroup
.
setClipPath
(
createLineClipPath
(
coordSys
,
true
,
seriesModel
));
lineGroup
.
setClipPath
(
createLineClipPath
(
this
,
coordSys
,
true
,
seriesModel
)
);
}
else
{
if
(
isAreaChart
&&
!
polygon
)
{
...
...
@@ -496,7 +525,9 @@ class LineView extends ChartView {
}
// Update clipPath
lineGroup
.
setClipPath
(
createLineClipPath
(
coordSys
,
false
,
seriesModel
));
lineGroup
.
setClipPath
(
createLineClipPath
(
this
,
coordSys
,
false
,
seriesModel
)
);
// Always update, or it is wrong in the case turning on legend
// because points are not changed
...
...
@@ -878,6 +909,59 @@ class LineView extends ChartView {
});
}
_initDuringLabel
(
seriesModel
:
LineSeriesModel
,
data
:
List
,
isUpdate
:
boolean
)
{
const
labelModel
=
seriesModel
.
getModel
(
'
label
'
);
const
showDuringLabel
=
labelModel
.
get
(
'
showDuringLabel
'
);
if
(
showDuringLabel
)
{
if
(
!
this
.
_duringLabel
)
{
this
.
_duringLabel
=
new
graphic
.
Text
({
style
:
{
text
:
'
abcd
'
}
});
this
.
group
.
add
(
this
.
_duringLabel
);
}
// const defaultTextGetter = (values: ParsedValue | ParsedValue[]) => {
// return getDefaultLabel(seriesModel.getData(), 0, values);
// };
// (isUpdate ? updateLabel : initLabel)(
// this._duringLabel, data, 0, labelModel, seriesModel, seriesModel, defaultTextGetter
// );
}
}
_updateDuringLabel
(
percent
:
number
,
clipRect
:
graphic
.
Rect
,
data
:
List
)
{
console
.
log
(
percent
,
clipRect
.
shape
)
if
(
this
.
_duringLabel
)
{
this
.
_duringLabel
.
attr
({
x
:
clipRect
.
shape
.
x
+
clipRect
.
shape
.
width
+
10
,
y
:
0
});
const
baseAxis
=
this
.
_coordSys
.
getBaseAxis
();
let
splitFound
=
false
;
let
left
=
null
;
data
.
each
(
function
(
idx
)
{
const
right
=
data
.
getValues
(
idx
);
console
.
log
(
right
);
});
const
host
=
inner
(
this
.
_duringLabel
);
}
}
/**
* @private
*/
...
...
src/label/labelStyle.ts
浏览文件 @
84ce59fc
...
...
@@ -62,6 +62,7 @@ interface SetLabelStyleOpt<LDI> extends TextCommonParams {
}
type
LabelModel
=
Model
<
LabelOption
&
{
formatter
?:
string
|
((
params
:
any
)
=>
string
);
showDuringLabel
?:
boolean
// Currently only supported by line charts
}
>
;
type
LabelModelForText
=
Model
<
Omit
<
// Remove
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录