Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
missman
incubator-echarts
提交
009a8a87
I
incubator-echarts
项目概览
missman
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
009a8a87
编写于
12月 28, 2017
作者:
P
pissang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some tiny optimizations on List.
上级
14c994f9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
18 deletion
+38
-18
src/data/List.js
src/data/List.js
+38
-18
未找到文件。
src/data/List.js
浏览文件 @
009a8a87
...
...
@@ -172,7 +172,7 @@ var List = function (dimensions, hostModel) {
else
{
dimensionInfo
=
dimensions
[
i
];
dimensionName
=
dimensionInfo
.
name
;
dimensionInfo
.
type
=
dimensionInfo
.
type
||
'
number
'
;
dimensionInfo
.
type
=
dimensionInfo
.
type
||
'
float
'
;
if
(
!
dimensionInfo
.
coordDim
)
{
dimensionInfo
.
coordDim
=
dimensionName
;
dimensionInfo
.
coordDimIndex
=
0
;
...
...
@@ -577,6 +577,10 @@ listProto.getIndices = function () {
* @return {number}
*/
listProto
.
get
=
function
(
dim
,
idx
,
stack
)
{
if
(
idx
<
0
||
idx
>=
this
.
_count
)
{
return
NaN
;
}
idx
=
this
.
getRawIndex
(
idx
);
var
storage
=
this
.
_storage
;
...
...
@@ -584,7 +588,7 @@ listProto.get = function (dim, idx, stack) {
var
chunkOffset
=
idx
%
this
.
_chunkSize
;
var
chunkStore
=
storage
[
dim
][
chunkIndex
];
var
value
=
chunkStore
?
chunkStore
[
chunkOffset
]
:
NaN
;
var
value
=
chunkStore
[
chunkOffset
]
;
// FIXME ordinal data type is not stackable
if
(
stack
)
{
var
dimensionInfo
=
this
.
_dimensionInfos
[
dim
];
...
...
@@ -603,6 +607,7 @@ listProto.get = function (dim, idx, stack) {
}
}
}
return
value
;
};
...
...
@@ -657,7 +662,6 @@ listProto.hasValue = function (idx) {
* @param {Function} filter
*/
listProto
.
getDataExtent
=
function
(
dim
,
stack
,
filter
)
{
console
.
time
(
'
getExtent
'
);
// Make sure use concrete dim as cache name.
dim
=
this
.
getDimension
(
dim
);
var
dimData
=
this
.
_storage
[
dim
];
...
...
@@ -719,7 +723,6 @@ listProto.getDataExtent = function (dim, stack, filter) {
}
this
.
_extent
[
cacheName
]
=
dimExtent
;
// console.timeEnd('getExtent');
return
dimExtent
;
};
...
...
@@ -887,13 +890,18 @@ listProto.indicesOfNearest = function (dim, value, stack, maxDistance) {
* @param {number} idx
* @return {number}
*/
listProto
.
getRawIndex
=
function
(
idx
)
{
if
(
!
this
.
_indices
)
{
return
idx
;
listProto
.
getRawIndex
=
getRawIndexWithoutIndices
;
function
getRawIndexWithoutIndices
(
idx
)
{
return
idx
;
}
function
getRawIndexWithIndices
(
idx
)
{
if
(
idx
<
this
.
_count
&&
idx
>=
0
)
{
return
this
.
_indices
[
idx
];
}
var
rawIdx
=
this
.
_indices
[
idx
];
return
rawIdx
==
null
?
-
1
:
rawIdx
;
};
return
-
1
;
}
/**
* Get raw data item
...
...
@@ -1000,35 +1008,39 @@ listProto.each = function (dims, cb, stack, context) {
* @param {*} [context=this]
*/
listProto
.
filterSelf
=
function
(
dimensions
,
cb
,
stack
,
context
)
{
'
use strict
'
;
if
(
typeof
dimensions
===
'
function
'
)
{
context
=
stack
;
stack
=
cb
;
cb
=
dimensions
;
dimensions
=
[];
}
stack
=
stack
||
false
;
dimensions
=
zrUtil
.
map
(
normalizeDimensions
(
dimensions
),
this
.
getDimension
,
this
);
var
Ctor
=
getIndicesCtor
(
this
.
count
());
var
newIndices
=
new
Ctor
(
this
.
count
());
var
count
=
this
.
count
();
var
Ctor
=
getIndicesCtor
(
count
);
var
newIndices
=
new
Ctor
(
count
);
var
value
=
[];
var
dimSize
=
dimensions
.
length
;
context
=
context
||
this
;
var
offset
=
0
;
for
(
var
i
=
0
;
i
<
this
.
count
();
i
++
)
{
var
dim0
=
dimensions
[
0
];
for
(
var
i
=
0
;
i
<
count
;
i
++
)
{
var
keep
;
// Simple optimization
if
(
!
dimSize
)
{
if
(
dimSize
===
0
)
{
keep
=
cb
.
call
(
context
,
i
);
}
else
if
(
dimSize
===
1
)
{
keep
=
cb
.
call
(
context
,
this
.
get
(
dimensions
[
0
],
i
,
stack
),
i
);
keep
=
cb
.
call
(
context
,
this
.
get
(
dim0
,
i
,
stack
),
i
);
}
else
{
for
(
var
k
=
0
;
k
<
dimSize
;
k
++
)
{
...
...
@@ -1043,11 +1055,15 @@ listProto.filterSelf = function (dimensions, cb, stack, context) {
}
// Set indices after filtered.
this
.
_indices
=
newIndices
;
if
(
offset
<
count
)
{
this
.
_indices
=
newIndices
;
}
this
.
_count
=
offset
;
// Reset data extent
this
.
_extent
=
{};
this
.
getRawIndex
=
this
.
_indices
?
getRawIndexWithIndices
:
getRawIndexWithoutIndices
;
return
this
;
};
...
...
@@ -1123,6 +1139,7 @@ listProto.map = function (dimensions, cb, stack, context) {
// Following properties are all immutable.
// So we can reference to the same value
list
.
_indices
=
this
.
_indices
;
list
.
getRawIndex
=
list
.
_indices
?
getRawIndexWithIndices
:
getRawIndexWithoutIndices
;
var
storage
=
list
.
_storage
;
...
...
@@ -1198,6 +1215,8 @@ listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) {
list
.
_count
=
offset
;
list
.
_indices
=
newIndices
;
list
.
getRawIndex
=
getRawIndexWithIndices
;
return
list
;
};
...
...
@@ -1449,6 +1468,7 @@ listProto.cloneShallow = function (list) {
else
{
list
.
_indices
=
null
;
}
list
.
getRawIndex
=
list
.
_indices
?
getRawIndexWithIndices
:
getRawIndexWithoutIndices
;
list
.
_extent
=
zrUtil
.
clone
(
this
.
_extent
);
list
.
_approximateExtent
=
zrUtil
.
clone
(
this
.
_approximateExtent
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录