Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
a77894c8
I
incubator-echarts
项目概览
半栈学徒
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
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,发现更多精彩内容 >>
提交
a77894c8
编写于
10月 14, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'bugfixes' into next
上级
2f566e92
f7ac75ec
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
58 deletion
+72
-58
src/chart/line/LineView.ts
src/chart/line/LineView.ts
+66
-6
src/chart/line/poly.ts
src/chart/line/poly.ts
+0
-50
src/util/states.ts
src/util/states.ts
+6
-2
未找到文件。
src/chart/line/LineView.ts
浏览文件 @
a77894c8
...
...
@@ -357,6 +357,59 @@ function canShowAllSymbolForCategory(
return
true
;
}
function
isPointNull
(
x
:
number
,
y
:
number
)
{
return
isNaN
(
x
)
||
isNaN
(
y
);
}
function
getLastIndexNotNull
(
points
:
ArrayLike
<
number
>
)
{
let
len
=
points
.
length
/
2
;
for
(;
len
>
0
;
len
--
)
{
if
(
!
isPointNull
(
points
[
len
*
2
-
2
],
points
[
len
*
2
-
1
]))
{
break
;
}
}
return
len
-
1
;
}
function
getPointAtIndex
(
points
:
ArrayLike
<
number
>
,
idx
:
number
)
{
return
[
points
[
idx
*
2
],
points
[
idx
*
2
+
1
]];
}
function
getIndexRange
(
points
:
ArrayLike
<
number
>
,
xOrY
:
number
,
dim
:
'
x
'
|
'
y
'
)
{
const
len
=
points
.
length
/
2
;
const
dimIdx
=
dim
===
'
x
'
?
0
:
1
;
let
a
;
let
b
;
let
prevIndex
=
0
;
let
nextIndex
=
-
1
;
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
b
=
points
[
i
*
2
+
dimIdx
];
if
(
isNaN
(
b
)
||
isNaN
(
points
[
i
*
2
+
1
-
dimIdx
]))
{
continue
;
}
if
(
i
===
0
)
{
a
=
b
;
continue
;
}
if
(
a
<=
xOrY
&&
b
>=
xOrY
||
a
>=
xOrY
&&
b
<=
xOrY
)
{
nextIndex
=
i
;
break
;
}
prevIndex
=
i
;
a
=
b
;
}
return
{
range
:
[
prevIndex
,
nextIndex
],
t
:
(
xOrY
-
a
)
/
(
b
-
a
)
};
}
interface
EndLabelAnimationRecord
{
lastFrameIndex
:
number
originalX
?:
number
...
...
@@ -393,8 +446,14 @@ function createLineClipPath(
const
isHorizontal
=
coordSys
.
getBaseAxis
().
isHorizontal
();
const
clipPath
=
createGridClipPath
(
coordSys
,
hasAnimation
,
seriesModel
,
()
=>
{
if
(
lineView
.
_endLabel
&&
labelAnimationRecord
.
originalX
!=
null
)
{
lineView
.
_endLabel
.
attr
({
x
:
labelAnimationRecord
.
originalX
,
y
:
labelAnimationRecord
.
originalY
});
const
endLabel
=
lineView
.
_endLabel
;
if
(
endLabel
&&
hasAnimation
)
{
if
(
labelAnimationRecord
.
originalX
!=
null
)
{
endLabel
.
attr
({
x
:
labelAnimationRecord
.
originalX
,
y
:
labelAnimationRecord
.
originalY
});
}
}
},
during
);
// Expand clip shape to avoid clipping when line value exceeds axis
...
...
@@ -995,7 +1054,7 @@ class LineView extends ChartView {
}
// Find last non-NaN data to display data
const
dataIndex
=
this
.
_polyline
.
getLastIndexNotNull
(
);
const
dataIndex
=
getLastIndexNotNull
(
data
.
getLayout
(
'
points
'
)
);
if
(
dataIndex
>=
0
)
{
setLabelStyle
(
endLabel
,
...
...
@@ -1039,6 +1098,7 @@ class LineView extends ChartView {
animationRecord
.
originalY
=
endLabel
.
y
;
}
const
points
=
data
.
getLayout
(
'
points
'
);
const
seriesModel
=
data
.
hostModel
as
LineSeriesModel
;
const
connectNulls
=
seriesModel
.
get
(
'
connectNulls
'
);
const
precision
=
endLabelModel
.
get
(
'
precision
'
);
...
...
@@ -1053,7 +1113,7 @@ class LineView extends ChartView {
:
isHorizontal
?
(
clipShape
.
x
+
clipShape
.
width
)
:
clipShape
.
y
;
const
dim
=
isHorizontal
?
'
x
'
:
'
y
'
;
const
dataIndexRange
=
polyline
.
getIndexRange
(
xOrY
,
dim
);
const
dataIndexRange
=
getIndexRange
(
points
,
xOrY
,
dim
);
const
indices
=
dataIndexRange
.
range
;
const
diff
=
indices
[
1
]
-
indices
[
0
];
...
...
@@ -1061,7 +1121,7 @@ class LineView extends ChartView {
if
(
diff
>=
1
)
{
// diff > 1 && connectNulls, which is on the null data.
if
(
diff
>
1
&&
!
connectNulls
)
{
const
pt
=
polyline
.
getPointAtIndex
(
indices
[
0
]);
const
pt
=
getPointAtIndex
(
points
,
indices
[
0
]);
endLabel
.
attr
({
x
:
pt
[
0
],
y
:
pt
[
1
]
});
valueAnimation
&&
(
value
=
seriesModel
.
getRawValue
(
indices
[
0
])
as
ParsedValue
);
}
...
...
@@ -1081,7 +1141,7 @@ class LineView extends ChartView {
// If diff <= 0, which is the range is not found(Include NaN)
// Choose the first point or last point.
const
idx
=
(
percent
===
1
||
animationRecord
.
lastFrameIndex
>
0
)
?
indices
[
0
]
:
0
;
const
pt
=
polyline
.
getPointAtIndex
(
idx
);
const
pt
=
getPointAtIndex
(
points
,
idx
);
valueAnimation
&&
(
value
=
seriesModel
.
getRawValue
(
idx
)
as
ParsedValue
);
endLabel
.
attr
({
x
:
pt
[
0
],
y
:
pt
[
1
]
});
}
...
...
src/chart/line/poly.ts
浏览文件 @
a77894c8
...
...
@@ -260,56 +260,6 @@ export class ECPolyline extends Path<ECPolylineProps> {
}
}
getLastIndexNotNull
()
{
const
points
=
this
.
shape
.
points
;
let
len
=
points
.
length
/
2
;
for
(;
len
>
0
;
len
--
)
{
if
(
!
isPointNull
(
points
[
len
*
2
-
2
],
points
[
len
*
2
-
1
]))
{
break
;
}
}
return
len
-
1
;
}
getPointAtIndex
(
idx
:
number
)
{
const
points
=
this
.
shape
.
points
;
return
[
points
[
idx
*
2
],
points
[
idx
*
2
+
1
]];
}
getIndexRange
(
xOrY
:
number
,
dim
:
'
x
'
|
'
y
'
)
{
const
points
=
this
.
shape
.
points
;
const
len
=
points
.
length
/
2
;
const
dimIdx
=
dim
===
'
x
'
?
0
:
1
;
let
a
;
let
b
;
let
prevIndex
=
0
;
let
nextIndex
=
-
1
;
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
b
=
points
[
i
*
2
+
dimIdx
];
if
(
isNaN
(
b
)
||
isNaN
(
points
[
i
*
2
+
1
-
dimIdx
]))
{
continue
;
}
if
(
i
===
0
)
{
a
=
b
;
continue
;
}
if
(
a
<=
xOrY
&&
b
>=
xOrY
||
a
>=
xOrY
&&
b
<=
xOrY
)
{
nextIndex
=
i
;
break
;
}
prevIndex
=
i
;
a
=
b
;
}
return
{
range
:
[
prevIndex
,
nextIndex
],
t
:
(
xOrY
-
a
)
/
(
b
-
a
)
};
}
getPointOn
(
xOrY
:
number
,
dim
:
'
x
'
|
'
y
'
):
number
[]
{
if
(
!
this
.
path
)
{
this
.
createPathProxy
();
...
...
src/util/states.ts
浏览文件 @
a77894c8
...
...
@@ -100,7 +100,9 @@ function singleEnterEmphasis(el: ECElement) {
function
singleLeaveEmphasis
(
el
:
ECElement
)
{
// Only mark the flag.
// States will be applied in the echarts.ts in next frame.
doChangeHoverState
(
el
,
'
normal
'
,
HOVER_STATE_NORMAL
);
if
(
el
.
hoverState
===
HOVER_STATE_EMPHASIS
)
{
doChangeHoverState
(
el
,
'
normal
'
,
HOVER_STATE_NORMAL
);
}
}
function
singleEnterBlur
(
el
:
ECElement
)
{
...
...
@@ -108,7 +110,9 @@ function singleEnterBlur(el: ECElement) {
}
function
singleLeaveBlur
(
el
:
ECElement
)
{
doChangeHoverState
(
el
,
'
normal
'
,
HOVER_STATE_NORMAL
);
if
(
el
.
hoverState
===
HOVER_STATE_BLUR
)
{
doChangeHoverState
(
el
,
'
normal
'
,
HOVER_STATE_NORMAL
);
}
}
function
singleEnterSelect
(
el
:
ECElement
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录