Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
a31dbfad
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,发现更多精彩内容 >>
提交
a31dbfad
编写于
12月 28, 2017
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[lines] Support appendData
上级
d2ae099b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
44 deletion
+47
-44
src/chart/lines/LinesSeries.js
src/chart/lines/LinesSeries.js
+47
-44
未找到文件。
src/chart/lines/LinesSeries.js
浏览文件 @
a31dbfad
import
{
__DEV__
}
from
'
../../config
'
;
import
SeriesModel
from
'
../../model/Series
'
;
import
List
from
'
../../data/List
'
;
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
{
concatArray
}
from
'
zrender/src/core/util
'
;
import
{
encodeHTML
}
from
'
../../util/format
'
;
import
CoordinateSystem
from
'
../../CoordinateSystem
'
;
...
...
@@ -10,33 +10,6 @@ var globalObj = typeof window === 'undefined' ? global : window;
var
Uint32Arr
=
globalObj
.
Uint32Array
||
Array
;
var
Float64Arr
=
globalObj
.
Float64Array
||
Array
;
// Convert [ [{coord: []}, {coord: []}] ]
// to [ { coords: [[]] } ]
function
preprocessOption
(
seriesOpt
)
{
var
data
=
seriesOpt
.
data
;
if
(
data
&&
data
[
0
]
&&
data
[
0
][
0
]
&&
data
[
0
][
0
].
coord
)
{
if
(
__DEV__
)
{
console
.
warn
(
'
Lines data configuration has been changed to
'
+
'
{ coords:[[1,2],[2,3]] }
'
);
}
seriesOpt
.
data
=
zrUtil
.
map
(
data
,
function
(
itemOpt
)
{
var
coords
=
[
itemOpt
[
0
].
coord
,
itemOpt
[
1
].
coord
];
var
target
=
{
coords
:
coords
};
if
(
itemOpt
[
0
].
name
)
{
target
.
fromName
=
itemOpt
[
0
].
name
;
}
if
(
itemOpt
[
1
].
name
)
{
target
.
toName
=
itemOpt
[
1
].
name
;
}
return
zrUtil
.
mergeAll
([
target
,
itemOpt
[
0
],
itemOpt
[
1
]]);
});
}
}
var
LinesSeries
=
SeriesModel
.
extend
({
type
:
'
series.lines
'
,
...
...
@@ -46,20 +19,44 @@ var LinesSeries = SeriesModel.extend({
visualColorAccessPath
:
'
lineStyle.color
'
,
init
:
function
(
option
)
{
// Not using preprocessor because mergeOption may not have series.type
preprocessOption
(
option
);
this
.
_processFlatCoordsArray
(
option
);
var
result
=
this
.
_processFlatCoordsArray
(
option
.
data
);
this
.
_flatCoords
=
result
.
flatCoords
;
this
.
_flatCoordsOffset
=
result
.
flatCoordsOffset
;
if
(
result
.
flatCoords
)
{
option
.
data
=
new
Float32Array
(
result
.
count
);
}
LinesSeries
.
superApply
(
this
,
'
init
'
,
arguments
);
},
mergeOption
:
function
(
option
)
{
preprocessOption
(
option
);
this
.
_processFlatCoordsArray
(
option
);
var
result
=
this
.
_processFlatCoordsArray
(
option
.
data
);
this
.
_flatCoords
=
result
.
flatCoords
;
this
.
_flatCoordsOffset
=
result
.
flatCoordsOffset
;
if
(
result
.
flatCoords
)
{
option
.
data
=
new
Float32Array
(
result
.
count
);
}
LinesSeries
.
superApply
(
this
,
'
mergeOption
'
,
arguments
);
},
appendData
:
function
(
params
)
{
var
result
=
this
.
_processFlatCoordsArray
(
params
.
data
);
if
(
result
.
flatCoords
)
{
if
(
!
this
.
_flatCoords
)
{
this
.
_flatCoords
=
result
.
flatCoords
;
this
.
_flatCoordsOffset
=
result
.
flatCoordsOffset
;
}
else
{
this
.
_flatCoords
=
concatArray
(
this
.
_flatCoords
,
result
.
flatCoords
);
this
.
_flatCoordsOffset
=
concatArray
(
this
.
_flatCoordsOffset
,
result
.
flatCoordsOffset
);
}
params
.
data
=
new
Float32Array
(
result
.
count
);
}
this
.
getRawData
().
appendData
(
params
.
data
);
},
_getCoordsFromItemModel
:
function
(
idx
)
{
var
itemModel
=
this
.
getData
().
getItemModel
(
idx
);
var
coords
=
(
itemModel
.
option
instanceof
Array
)
...
...
@@ -104,8 +101,11 @@ var LinesSeries = SeriesModel.extend({
}
},
_processFlatCoordsArray
:
function
(
option
)
{
var
data
=
option
.
data
;
_processFlatCoordsArray
:
function
(
data
)
{
var
startOffset
=
0
;
if
(
this
.
_flatCoords
)
{
startOffset
=
this
.
_flatCoords
.
length
;
}
// Stored as a typed array. In format
// Points Count(2) | x | y | x | y | Points Count(3) | x | y | x | y | x | y |
if
(
typeof
data
[
0
]
===
'
number
'
)
{
...
...
@@ -120,7 +120,7 @@ var LinesSeries = SeriesModel.extend({
dataCount
++
;
var
count
=
data
[
i
++
];
// Offset
coordsOffsetAndLenStorage
[
offsetCursor
++
]
=
coordsCursor
;
coordsOffsetAndLenStorage
[
offsetCursor
++
]
=
coordsCursor
+
startOffset
;
// Len
coordsOffsetAndLenStorage
[
offsetCursor
++
]
=
count
;
for
(
var
k
=
0
;
k
<
count
;
k
++
)
{
...
...
@@ -137,15 +137,18 @@ var LinesSeries = SeriesModel.extend({
}
}
this
.
_flatCoordsOffset
=
coordsOffsetAndLenStorage
;
this
.
_flatCoords
=
coordsStorage
;
// Fill with zero values.
option
.
data
=
new
Float32Array
(
dataCount
);
}
else
{
this
.
_flatCoordsOffset
=
this
.
_flatCoords
=
null
;
return
{
flatCoordsOffset
:
new
Uint32Array
(
coordsOffsetAndLenStorage
.
buffer
,
0
,
offsetCursor
),
flatCoords
:
coordsStorage
,
count
:
dataCount
};
}
return
{
flatCoordsOffset
:
null
,
flatCoords
:
null
,
count
:
data
.
length
};
},
getInitialData
:
function
(
option
,
ecModel
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录