Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
7b7a7470
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 搜索 >>
提交
7b7a7470
编写于
9月 17, 2020
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf(line): optimize performance of time series data on line.
上级
9b991a41
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
68 addition
and
8 deletion
+68
-8
src/chart/line/LineView.ts
src/chart/line/LineView.ts
+8
-4
src/coord/cartesian/Cartesian2D.ts
src/coord/cartesian/Cartesian2D.ts
+52
-0
src/coord/cartesian/Grid.ts
src/coord/cartesian/Grid.ts
+6
-4
src/scale/Scale.ts
src/scale/Scale.ts
+2
-0
未找到文件。
src/chart/line/LineView.ts
浏览文件 @
7b7a7470
...
...
@@ -43,7 +43,6 @@ import { CoordinateSystemClipArea } from '../../coord/CoordinateSystem';
import
{
setStatesStylesFromModel
,
setStatesFlag
,
enableHoverEmphasis
}
from
'
../../util/states
'
;
import
{
getECData
}
from
'
../../util/ecData
'
;
import
{
createFloat32Array
}
from
'
../../util/vendor
'
;
import
{
createSymbol
}
from
'
../../util/symbol
'
;
type
PolarArea
=
ReturnType
<
Polar
[
'
getArea
'
]
>
;
...
...
@@ -433,7 +432,7 @@ class LineView extends ChartView {
const
valueOrigin
=
areaStyleModel
.
get
(
'
origin
'
);
const
dataCoordInfo
=
prepareDataCoordInfo
(
coordSys
,
data
,
valueOrigin
);
let
stackedOnPoints
=
getStackedOnPoints
(
coordSys
,
data
,
dataCoordInfo
);
let
stackedOnPoints
=
isAreaChart
&&
getStackedOnPoints
(
coordSys
,
data
,
dataCoordInfo
);
const
showSymbol
=
seriesModel
.
get
(
'
showSymbol
'
);
...
...
@@ -490,8 +489,11 @@ class LineView extends ChartView {
if
(
step
)
{
// TODO If stacked series is not step
points
=
turnPointsIntoStep
(
points
,
coordSys
,
step
);
if
(
stackedOnPoints
)
{
stackedOnPoints
=
turnPointsIntoStep
(
stackedOnPoints
,
coordSys
,
step
);
}
}
polyline
=
this
.
_newPolyline
(
points
);
if
(
isAreaChart
)
{
...
...
@@ -548,8 +550,10 @@ class LineView extends ChartView {
if
(
step
)
{
// TODO If stacked series is not step
points
=
turnPointsIntoStep
(
points
,
coordSys
,
step
);
if
(
stackedOnPoints
)
{
stackedOnPoints
=
turnPointsIntoStep
(
stackedOnPoints
,
coordSys
,
step
);
}
}
polyline
.
setShape
({
points
:
points
...
...
src/coord/cartesian/Cartesian2D.ts
浏览文件 @
7b7a7470
...
...
@@ -25,9 +25,16 @@ import Axis2D from './Axis2D';
import
{
CoordinateSystem
}
from
'
../CoordinateSystem
'
;
import
GridModel
from
'
./GridModel
'
;
import
Grid
from
'
./Grid
'
;
import
Scale
from
'
../../scale/Scale
'
;
import
{
invert
}
from
'
zrender/src/core/matrix
'
;
import
{
applyTransform
}
from
'
zrender/src/core/vector
'
;
export
const
cartesian2DDimensions
=
[
'
x
'
,
'
y
'
];
function
canCalculateAffineTransform
(
scale
:
Scale
)
{
return
scale
.
type
===
'
interval
'
||
scale
.
type
===
'
time
'
;
}
class
Cartesian2D
extends
Cartesian
<
Axis2D
>
implements
CoordinateSystem
{
readonly
type
=
'
cartesian2d
'
;
...
...
@@ -38,6 +45,45 @@ class Cartesian2D extends Cartesian<Axis2D> implements CoordinateSystem {
master
:
Grid
;
private
_transform
:
number
[];
private
_invTransform
:
number
[];
/**
* Calculate an affine transform matrix if two axes are time or value.
* It's mainly for accelartion on the large time series data.
*/
calcAffineTransform
()
{
this
.
_transform
=
this
.
_invTransform
=
null
;
const
xAxisScale
=
this
.
getAxis
(
'
x
'
).
scale
;
const
yAxisScale
=
this
.
getAxis
(
'
y
'
).
scale
;
if
(
!
canCalculateAffineTransform
(
xAxisScale
)
||
!
canCalculateAffineTransform
(
yAxisScale
))
{
return
;
}
const
xScaleExtent
=
xAxisScale
.
getExtent
();
const
yScaleExtent
=
yAxisScale
.
getExtent
();
const
start
=
this
.
dataToPoint
([
xScaleExtent
[
0
],
yScaleExtent
[
0
]]);
const
end
=
this
.
dataToPoint
([
xScaleExtent
[
1
],
yScaleExtent
[
1
]]);
const
xScaleSpan
=
xScaleExtent
[
1
]
-
xScaleExtent
[
0
];
const
yScaleSpan
=
yScaleExtent
[
1
]
-
yScaleExtent
[
0
];
if
(
!
xScaleSpan
||
!
yScaleSpan
)
{
return
;
}
// Accelerate data to point calculation on the special large time series data.
const
scaleX
=
(
end
[
0
]
-
start
[
0
])
/
xScaleSpan
;
const
scaleY
=
(
end
[
1
]
-
start
[
1
])
/
yScaleSpan
;
const
translateX
=
start
[
0
]
-
xScaleExtent
[
0
]
*
scaleX
;
const
translateY
=
start
[
1
]
-
yScaleExtent
[
0
]
*
scaleY
;
const
m
=
this
.
_transform
=
[
scaleX
,
0
,
0
,
scaleY
,
translateX
,
translateY
];
this
.
_invTransform
=
invert
([],
m
);
}
/**
* Base axis will be used on stacking.
*/
...
...
@@ -60,6 +106,9 @@ class Cartesian2D extends Cartesian<Axis2D> implements CoordinateSystem {
}
dataToPoint
(
data
:
ScaleDataValue
[],
reserved
?:
unknown
,
out
?:
number
[]):
number
[]
{
if
(
this
.
_transform
)
{
return
applyTransform
(
out
||
[],
data
as
number
[],
this
.
_transform
);
}
const
xAxis
=
this
.
getAxis
(
'
x
'
);
const
yAxis
=
this
.
getAxis
(
'
y
'
);
out
=
out
||
[];
...
...
@@ -89,6 +138,9 @@ class Cartesian2D extends Cartesian<Axis2D> implements CoordinateSystem {
}
pointToData
(
point
:
number
[],
out
?:
number
[]):
number
[]
{
if
(
this
.
_invTransform
)
{
return
applyTransform
(
out
,
point
,
this
.
_invTransform
);
}
const
xAxis
=
this
.
getAxis
(
'
x
'
);
const
yAxis
=
this
.
getAxis
(
'
y
'
);
out
=
out
||
[];
...
...
src/coord/cartesian/Grid.ts
浏览文件 @
7b7a7470
...
...
@@ -152,6 +152,12 @@ class Grid implements CoordinateSystemMaster {
adjustAxes
();
}
each
(
this
.
_coordsList
,
function
(
coord
)
{
// Calculate affine matrix to accelerate the data to point transform.
// If all the axes scales are time or value.
coord
.
calcAffineTransform
();
});
function
adjustAxes
()
{
each
(
axesList
,
function
(
axis
)
{
const
isHorizontal
=
axis
.
isHorizontal
();
...
...
@@ -407,10 +413,6 @@ class Grid implements CoordinateSystemMaster {
* Update cartesian properties from series.
*/
private
_updateScale
(
ecModel
:
GlobalModel
,
gridModel
:
GridModel
):
void
{
const
sortedDataValue
:
number
[]
=
[];
const
sortedDataIndex
:
number
[]
=
[];
let
hasCategoryIndices
=
false
;
// Reset scale
each
(
this
.
_axesList
,
function
(
axis
)
{
axis
.
scale
.
setExtent
(
Infinity
,
-
Infinity
);
...
...
src/scale/Scale.ts
浏览文件 @
7b7a7470
...
...
@@ -97,6 +97,8 @@ abstract class Scale {
/**
* Get extent
*
* Extent is always in increase order.
*/
getExtent
():
[
number
,
number
]
{
return
this
.
_extent
.
slice
()
as
[
number
,
number
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录