Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
3e676fde
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,发现更多精彩内容 >>
提交
3e676fde
编写于
10月 10, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
List#map, List#mapArray
上级
cbc05ff8
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
113 addition
and
22 deletion
+113
-22
src/chart/line/LineView.js
src/chart/line/LineView.js
+2
-2
src/chart/line/lineAnimationDiff.js
src/chart/line/lineAnimationDiff.js
+2
-2
src/component/legend/LegendModel.js
src/component/legend/LegendModel.js
+1
-1
src/component/marker/MarkLineView.js
src/component/marker/MarkLineView.js
+1
-1
src/coord/cartesian/Cartesian2D.js
src/coord/cartesian/Cartesian2D.js
+1
-1
src/coord/cartesian/Grid.js
src/coord/cartesian/Grid.js
+13
-7
src/coord/cartesian/GridModel.js
src/coord/cartesian/GridModel.js
+0
-1
src/coord/polar/Polar.js
src/coord/polar/Polar.js
+1
-1
src/data/List.js
src/data/List.js
+70
-3
test/dataZoom-scatter-hv.html
test/dataZoom-scatter-hv.html
+3
-0
test/ut/spec/data/List.js
test/ut/spec/data/List.js
+19
-3
未找到文件。
src/chart/line/LineView.js
浏览文件 @
3e676fde
...
...
@@ -57,7 +57,7 @@ define(function(require) {
// var dims = coordSys.type === 'cartesian2d' ? ['x', 'y'] : ['radius', 'angle'];
var
baseDataOffset
=
valueDim
===
'
x
'
||
valueDim
===
'
radius
'
?
1
:
0
;
return
data
.
map
([
valueDim
],
function
(
val
,
idx
)
{
return
data
.
map
Array
([
valueDim
],
function
(
val
,
idx
)
{
var
stackedOnSameSign
;
var
stackedOn
=
data
.
stackedOn
;
// Find first stacked value with same sign
...
...
@@ -93,7 +93,7 @@ define(function(require) {
var
lineStyleModel
=
seriesModel
.
getModel
(
'
itemStyle.normal.lineStyle
'
);
var
areaStyleModel
=
seriesModel
.
getModel
(
'
itemStyle.normal.areaStyle
'
);
var
points
=
data
.
map
(
data
.
getItemLayout
,
true
);
var
points
=
data
.
map
Array
(
data
.
getItemLayout
,
true
);
var
isCoordSysPolar
=
coordSys
.
type
===
'
polar
'
;
var
prevCoordSys
=
this
.
_coordSys
;
...
...
src/chart/line/lineAnimationDiff.js
浏览文件 @
3e676fde
...
...
@@ -43,8 +43,8 @@ define(function (require) {
oldCoordSys
,
newCoordSys
)
{
var
newNameList
=
newData
.
map
(
newData
.
getName
);
var
oldNameList
=
oldData
.
map
(
oldData
.
getName
);
var
newNameList
=
newData
.
map
Array
(
newData
.
getName
);
var
oldNameList
=
oldData
.
map
Array
(
oldData
.
getName
);
var
currPoints
=
[];
var
nextPoints
=
[];
...
...
src/component/legend/LegendModel.js
浏览文件 @
3e676fde
...
...
@@ -31,7 +31,7 @@ define(function(require) {
ecModel
.
eachSeries
(
function
(
seriesModel
)
{
if
(
seriesModel
.
legendDataProvider
)
{
var
data
=
seriesModel
.
legendDataProvider
();
availableNames
=
availableNames
.
concat
(
data
.
map
(
data
.
getName
));
availableNames
=
availableNames
.
concat
(
data
.
map
Array
(
data
.
getName
));
}
});
/**
...
...
src/component/marker/MarkLineView.js
浏览文件 @
3e676fde
...
...
@@ -104,7 +104,7 @@ define(function (require) {
if
(
!
zrUtil
.
isArray
(
symbolType
))
{
symbolType
=
[
symbolType
,
symbolType
];
}
if
(
typeof
(
+
symbolSize
)
===
'
number
'
)
{
if
(
typeof
symbolSize
===
'
number
'
)
{
symbolSize
=
[
symbolSize
,
symbolSize
];
}
...
...
src/coord/cartesian/Cartesian2D.js
浏览文件 @
3e676fde
...
...
@@ -59,7 +59,7 @@ define(function(require) {
* `[[10, 10], [20, 20], [30, 30]]`
*/
dataToPoints
:
function
(
data
,
stack
)
{
return
data
.
map
([
'
x
'
,
'
y
'
],
function
(
x
,
y
)
{
return
data
.
map
Array
([
'
x
'
,
'
y
'
],
function
(
x
,
y
)
{
return
this
.
dataToPoint
([
x
,
y
]);
},
stack
,
this
);
},
...
...
src/coord/cartesian/Grid.js
浏览文件 @
3e676fde
...
...
@@ -46,8 +46,8 @@ define(function(require, factory) {
*/
function
ifAxisCrossZero
(
axis
)
{
var
dataExtent
=
axis
.
scale
.
getExtent
();
return
(
dataExtent
[
0
]
>
0
&&
dataExtent
[
1
]
>
0
)
||
(
dataExtent
[
0
]
<
0
&&
dataExtent
[
1
]
<
0
)
return
!
(
(
dataExtent
[
0
]
>
0
&&
dataExtent
[
1
]
>
0
)
||
(
dataExtent
[
0
]
<
0
&&
dataExtent
[
1
]
<
0
)
)
||
ifAxisNeedsCrossZero
(
axis
);
}
/**
...
...
@@ -226,6 +226,17 @@ define(function(require, factory) {
this
.
_coordsMap
[
key
]
=
cartesian
;
this
.
_coordsList
.
push
(
cartesian
);
cartesian
.
addAxis
(
xAxis
);
cartesian
.
addAxis
(
yAxis
);
},
this
);
},
this
);
this
.
_updateCartesianFromSeries
(
ecModel
,
gridModel
);
// Fix configuration
zrUtil
.
each
(
axesMap
.
x
,
function
(
xAxis
)
{
zrUtil
.
each
(
axesMap
.
y
,
function
(
yAxis
)
{
// onZero can not be used in these two situations
// 1. When other axis is a category axis
// 2. When other axis not across 0 point
...
...
@@ -247,14 +258,9 @@ define(function(require, factory) {
xAxis
.
scale
.
unionExtent
([
0
,
0
]);
}
cartesian
.
addAxis
(
xAxis
);
cartesian
.
addAxis
(
yAxis
);
},
this
);
},
this
);
this
.
_updateCartesianFromSeries
(
ecModel
,
gridModel
);
function
createAxisCreator
(
axisType
)
{
return
function
(
axisModel
,
idx
)
{
if
(
!
isAxisUsedInTheGrid
(
axisModel
,
gridModel
,
ecModel
))
{
...
...
src/coord/cartesian/GridModel.js
浏览文件 @
3e676fde
...
...
@@ -12,7 +12,6 @@ define(function(require) {
dependencies
:
[
'
xAxis
'
,
'
yAxis
'
],
/**
/**
* @type {module:echarts/coord/cartesian/Grid}
*/
...
...
src/coord/polar/Polar.js
浏览文件 @
3e676fde
...
...
@@ -139,7 +139,7 @@ define(function(require) {
* `[[10, 10], [20, 20], [30, 30]]`
*/
dataToPoints
:
function
(
data
)
{
return
data
.
map
([
'
radius
'
,
'
angle
'
],
function
(
radius
,
angle
)
{
return
data
.
map
Array
([
'
radius
'
,
'
angle
'
],
function
(
radius
,
angle
)
{
return
this
.
dataToPoint
([
radius
,
angle
]);
},
this
);
},
...
...
src/data/List.js
浏览文件 @
3e676fde
...
...
@@ -542,13 +542,14 @@ define(function (require) {
};
/**
* Data mapping
* @param {string|Array.<string>}
* Data mapping
to a plain array
* @param {string|Array.<string>}
[dimensions]
* @param {Function} cb
* @param {boolean} [stack=false]
* @param {*} [context=this]
* @return {Array}
*/
listProto
.
map
=
function
(
dimensions
,
cb
,
stack
,
context
)
{
listProto
.
map
Array
=
function
(
dimensions
,
cb
,
stack
,
context
)
{
if
(
typeof
dimensions
===
'
function
'
)
{
context
=
stack
;
stack
=
cb
;
...
...
@@ -563,6 +564,72 @@ define(function (require) {
return
result
;
};
/**
* Data mapping to a new List with given dimensions
* @param {string|Array.<string>} dimensions
* @param {Function} cb
* @param {boolean} [stack=false]
* @param {*} [context=this]
* @return {Array}
*/
listProto
.
map
=
function
(
dimensions
,
cb
,
stack
,
context
)
{
var
list
=
new
List
(
zrUtil
.
map
(
dimensions
,
this
.
getDimensionInfo
,
this
),
this
.
hostModel
);
// Following properties are all immutable.
// So we can reference to the same value
list
.
_nameList
=
this
.
_nameList
;
var
indices
=
list
.
indices
=
this
.
indices
;
list
.
_rawValueDims
=
this
.
_rawValueDims
;
list
.
_optionModels
=
this
.
_optionModels
;
var
storage
=
list
.
_storage
=
{};
var
thisStorage
=
this
.
_storage
;
// Init storage
for
(
var
i
=
0
;
i
<
dimensions
.
length
;
i
++
)
{
var
dim
=
dimensions
[
i
];
var
dimStore
=
thisStorage
[
dim
];
if
(
dimStore
)
{
storage
[
dim
]
=
new
dimStore
.
constructor
(
thisStorage
[
dim
].
length
);
}
}
storage
.
$optionModelIndices
=
thisStorage
.
$optionModelIndices
;
var
tmpRetValue
=
[];
this
.
each
(
dimensions
,
function
()
{
var
idx
=
arguments
[
arguments
.
length
-
1
];
var
retValue
=
cb
&&
cb
.
apply
(
this
,
arguments
);
if
(
retValue
!=
null
)
{
// a number
if
(
typeof
retValue
===
'
number
'
)
{
tmpRetValue
[
0
]
=
retValue
;
retValue
=
tmpRetValue
;
}
for
(
var
i
=
0
;
i
<
retValue
.
length
;
i
++
)
{
var
dim
=
dimensions
[
i
];
var
dimStore
=
storage
[
dim
];
var
rawIdx
=
indices
[
idx
];
if
(
dimStore
)
{
dimStore
[
rawIdx
]
=
retValue
[
i
];
}
}
}
});
// FIXME Value may already been stacked
list
.
stackedOn
=
this
.
stackedOn
;
return
list
;
};
var
temporaryModel
=
new
Model
(
null
);
/**
* Get model of one data item.
...
...
test/dataZoom-scatter-hv.html
浏览文件 @
3e676fde
...
...
@@ -123,5 +123,8 @@
})
</script>
<script
src=
"js/memory-stats.js"
></script>
<script
src=
"js/memory.js"
></script>
</body>
</html>
\ No newline at end of file
test/ut/spec/data/List.js
浏览文件 @
3e676fde
...
...
@@ -57,8 +57,14 @@ describe('List', function () {
});
testCase
(
'
Stacked data
'
,
function
(
List
)
{
var
list1
=
new
List
([
'
x
'
,
'
y
'
]);
var
list2
=
new
List
([
'
x
'
,
'
y
'
]);
var
list1
=
new
List
([
'
x
'
,
{
name
:
'
y
'
,
stackable
:
true
}]);
var
list2
=
new
List
([
'
x
'
,
{
name
:
'
y
'
,
stackable
:
true
}]);
list1
.
initData
([
1
,
'
-
'
,
2
,
-
2
]);
list2
.
initData
([
1
,
2
,
3
,
2
]);
...
...
@@ -102,6 +108,16 @@ describe('List', function () {
var
list
=
new
List
([
'
x
'
,
'
y
'
]);
list
.
initData
([[
10
,
15
],
[
20
,
25
],
[
30
,
35
]]);
expect
(
list
.
map
([
'
x
'
,
'
y
'
],
function
(
x
,
y
)
{
return
[
x
+
2
,
y
+
2
];
}).
mapArray
(
'
x
'
,
function
(
x
)
{
return
x
;
})).
toEqual
([
12
,
22
,
32
]);
});
testCase
(
'
mapArray
'
,
function
(
List
)
{
var
list
=
new
List
([
'
x
'
,
'
y
'
]);
list
.
initData
([[
10
,
15
],
[
20
,
25
],
[
30
,
35
]]);
expect
(
list
.
mapArray
([
'
x
'
,
'
y
'
],
function
(
x
,
y
)
{
return
[
x
,
y
];
})).
toEqual
([[
10
,
15
],
[
20
,
25
],
[
30
,
35
]]);
});
...
...
@@ -111,7 +127,7 @@ describe('List', function () {
list
.
initData
([[
10
,
15
],
[
20
,
25
],
[
30
,
35
]]);
expect
(
list
.
filterSelf
([
'
x
'
,
'
y
'
],
function
(
x
,
y
)
{
return
x
<
30
&&
x
>
10
;
}).
map
(
'
x
'
,
function
(
x
)
{
}).
map
Array
(
'
x
'
,
function
(
x
)
{
return
x
;
})).
toEqual
([
20
]);
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录