Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alon@wen
echarts
提交
69764d37
E
echarts
项目概览
alon@wen
/
echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
69764d37
编写于
8月 31, 2015
作者:
P
pah100
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/pissang/echarts-next
上级
a07029fc
cc7d04ed
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
335 addition
and
204 deletion
+335
-204
src/chart/bar/BarSeries.js
src/chart/bar/BarSeries.js
+2
-2
src/chart/line/LineSeries.js
src/chart/line/LineSeries.js
+2
-2
src/chart/line/LineView.js
src/chart/line/LineView.js
+2
-2
src/component/axis.js
src/component/axis.js
+4
-9
src/coord/Axis.js
src/coord/Axis.js
+178
-0
src/coord/cartesian/Axis2D.js
src/coord/cartesian/Axis2D.js
+6
-7
src/coord/cartesian/Cartesian.js
src/coord/cartesian/Cartesian.js
+0
-19
src/coord/cartesian/Cartesian2D.js
src/coord/cartesian/Cartesian2D.js
+6
-14
src/coord/cartesian/Grid.js
src/coord/cartesian/Grid.js
+3
-12
src/data/List.js
src/data/List.js
+106
-132
src/echarts.js
src/echarts.js
+14
-2
src/scale/Ordinal.js
src/scale/Ordinal.js
+10
-3
src/view/Chart.js
src/view/Chart.js
+2
-0
未找到文件。
src/chart/bar/BarSeries.js
浏览文件 @
69764d37
...
...
@@ -8,8 +8,8 @@ define(function(require) {
type
:
'
bar
'
,
getInitialData
:
function
(
option
)
{
return
List
.
fromArray
(
option
.
data
,
1
,
this
);
getInitialData
:
function
(
option
,
ecModel
)
{
return
List
.
fromArray
(
option
.
data
,
this
,
ecModel
);
},
defaultOption
:
{
...
...
src/chart/line/LineSeries.js
浏览文件 @
69764d37
...
...
@@ -8,8 +8,8 @@ define(function(require) {
type
:
'
line
'
,
getInitialData
:
function
(
option
)
{
return
List
.
fromArray
(
option
.
data
,
1
,
this
);
getInitialData
:
function
(
option
,
ecModel
)
{
return
List
.
fromArray
(
option
.
data
,
this
,
ecModel
);
},
defaultOption
:
{
...
...
src/chart/line/LineView.js
浏览文件 @
69764d37
...
...
@@ -29,8 +29,8 @@ define(function(require) {
var
cartesian
=
seriesModel
.
coordinateSystem
;
var
xAxis
=
cartesian
.
getAxis
(
'
x
'
);
var
yAxis
=
cartesian
.
getAxis
(
'
y
'
);
var
xExtent
=
xAxis
.
get
Coord
Extent
();
var
yExtent
=
yAxis
.
get
Coord
Extent
();
var
xExtent
=
xAxis
.
getExtent
();
var
yExtent
=
yAxis
.
getExtent
();
var
clipPath
=
new
api
.
Rect
({
shape
:
{
...
...
src/component/axis.js
浏览文件 @
69764d37
...
...
@@ -50,7 +50,7 @@ define(function(require) {
var
grid
=
gridModel
.
coordinateSystem
;
var
rect
=
grid
.
getRect
();
var
otherAxis
=
grid
.
getAxis
(
axis
.
type
===
'
x
'
?
'
y
'
:
'
x
'
);
var
otherAxis
=
grid
.
getAxis
(
axis
.
dim
===
'
x
'
?
'
y
'
:
'
x
'
);
var
position
=
0
;
if
(
axisModel
.
get
(
'
axisLine.onZero
'
))
{
...
...
@@ -148,8 +148,7 @@ define(function(require) {
var
isOrdinalAxis
=
axis
.
scale
.
type
===
'
ordinal
'
;
var
axisPosition
=
axis
.
position
;
var
ticksCoords
=
isOrdinalAxis
&&
axis
.
boundaryGap
?
axis
.
getBandsCoords
(
true
)
:
axis
.
getTicksCoords
();
var
ticksCoords
=
axis
.
getTicksPositions
();
var
tickLines
=
[];
for
(
var
i
=
0
;
i
<
ticksCoords
.
length
;
i
++
)
{
...
...
@@ -388,9 +387,7 @@ define(function(require) {
var
splitLines
=
[];
var
lineCount
=
0
;
var
isOrdinalAxis
=
axis
.
scale
.
type
===
'
ordinal
'
;
var
ticksCoords
=
isOrdinalAxis
&&
axis
.
boundaryGap
?
axis
.
getBandsCoords
(
true
)
:
axis
.
getTicksCoords
();
var
ticksCoords
=
axis
.
getTicksPositions
();
var
p1
=
[];
var
p2
=
[];
...
...
@@ -452,9 +449,7 @@ define(function(require) {
var
areaColors
=
splitAreaModel
.
get
(
'
areaStyle.color
'
);
var
gridRect
=
gridModel
.
coordinateSystem
.
getRect
();
var
isOrdinalAxis
=
axis
.
scale
.
type
===
'
ordinal
'
;
var
ticksCoords
=
isOrdinalAxis
&&
axis
.
boundaryGap
?
axis
.
getBandsCoords
(
true
)
:
axis
.
getTicksCoords
();
var
ticksCoords
=
axis
.
getTicksPositions
();
var
prevX
;
var
prevY
;
...
...
src/coord/
cartesian/
Axis.js
→
src/coord/Axis.js
浏览文件 @
69764d37
define
(
function
(
require
)
{
var
linearMap
=
require
(
'
../
../
util/number
'
).
linearMap
;
var
linearMap
=
require
(
'
../util/number
'
).
linearMap
;
var
zrUtil
=
require
(
'
zrender/core/util
'
);
function
fixExtentWithBands
(
extent
,
nTick
)
{
var
size
=
extent
[
1
]
-
extent
[
0
];
var
len
=
nTick
;
var
margin
=
size
/
len
/
2
;
extent
[
0
]
+=
margin
;
extent
[
1
]
-=
margin
;
}
/**
* @name module:echarts/coord/CartesianAxis
* @constructor
*/
var
Axis
=
function
(
dim
,
scale
,
coordE
xtent
)
{
var
Axis
=
function
(
dim
,
scale
,
e
xtent
)
{
/**
* Axis dimension. Such as 'x', 'y', 'z'
* Axis dimension. Such as 'x', 'y', 'z'
, 'angle', 'radius'
* @type {string}
*/
this
.
dim
=
dim
;
...
...
@@ -25,12 +32,18 @@ define(function (require) {
* @type {Array.<number>}
* @private
*/
this
.
_
coordExtent
=
coordE
xtent
;
this
.
_
extent
=
e
xtent
;
/**
* @type {boolean}
*/
this
.
inverse
=
false
;
/**
* Usually true when axis has a ordinal scale
* @type {boolean}
*/
this
.
onBand
=
false
;
};
Axis
.
prototype
=
{
...
...
@@ -41,8 +54,8 @@ define(function (require) {
* Get coord extent
* @return {Array.<number>}
*/
get
Coord
Extent
:
function
()
{
var
ret
=
this
.
_
coordE
xtent
.
slice
();
getExtent
:
function
()
{
var
ret
=
this
.
_
e
xtent
.
slice
();
if
(
this
.
inverse
)
{
ret
.
reverse
();
}
...
...
@@ -54,19 +67,19 @@ define(function (require) {
* @param {number} min
* @param {number} max
*/
set
Coord
Extent
:
function
(
min
,
max
)
{
var
extent
=
this
.
_
coordE
xtent
;
setExtent
:
function
(
min
,
max
)
{
var
extent
=
this
.
_
e
xtent
;
extent
[
0
]
=
min
;
extent
[
1
]
=
max
;
},
/**
* Map a data to
coord
. Data is the rank if it has a ordinal scale
* Map a data to
extent
. Data is the rank if it has a ordinal scale
* @param {number} data
* @param {boolean} clamp
* @return {number}
*/
dataToCoord
:
function
(
data
,
clamp
)
{
mapData
:
function
(
data
,
clamp
)
{
// PENDING
if
(
data
==
null
||
data
===
'
-
'
)
{
return
NaN
;
...
...
@@ -74,75 +87,89 @@ define(function (require) {
data
=
this
.
scale
.
normalize
(
data
);
return
linearMap
(
data
,
[
0
,
1
],
this
.
getCoordExtent
(),
clamp
);
var
extent
=
this
.
getExtent
();
if
(
this
.
onBand
&&
this
.
scale
.
type
===
'
ordinal
'
)
{
fixExtentWithBands
(
extent
,
this
.
scale
.
getExtentSize
());
}
return
linearMap
(
data
,
[
0
,
1
],
extent
,
clamp
);
},
/**
*
Map a coord to
data. Data is the rank if it has a ordinal scale
* @param {number}
coor
d
*
Unmap a
data. Data is the rank if it has a ordinal scale
* @param {number}
mappe
d
* @param {boolean} clamp
* @return {number}
*/
coordToData
:
function
(
coord
,
clamp
)
{
var
t
=
linearMap
(
coord
,
this
.
getCoordExtent
(),
[
0
,
1
],
clamp
);
unmapData
:
function
(
mapped
,
clamp
)
{
var
extent
=
this
.
getExtent
();
if
(
this
.
onBand
&&
this
.
scale
.
type
===
'
ordinal
'
)
{
fixExtentWithBands
(
extent
,
this
.
scale
.
getExtentSize
());
}
var
t
=
linearMap
(
mapped
,
extent
,
[
0
,
1
],
clamp
);
return
this
.
scale
.
scale
(
t
);
},
/**
* @return {
ticks
}
* @return {
Array.<number>
}
*/
getTicks
Coord
s
:
function
()
{
getTicks
Position
s
:
function
()
{
var
ticks
=
this
.
scale
.
getTicks
();
return
zrUtil
.
map
(
ticks
,
function
(
data
)
{
return
this
.
dataToCoord
(
data
);
},
this
);
if
(
this
.
onBand
&&
this
.
scale
.
type
===
'
ordinal
'
)
{
var
bands
=
this
.
getBands
();
var
ret
=
[];
for
(
var
i
=
0
;
i
<
bands
.
length
;
i
++
)
{
ret
.
push
(
bands
[
i
][
0
]);
}
if
(
bands
[
i
-
1
])
{
ret
.
push
(
bands
[
i
-
1
][
1
]);
}
return
ret
;
}
else
{
return
zrUtil
.
map
(
ticks
,
this
.
mapData
,
this
);
}
},
/**
* Get
coords of
bands.
* Get bands.
* If axis has ticks [1, 2, 3, 4]. Bands on the axis are
* |---1---|---2---|---3---|---4---|. And band coords is an array of coords
* where `|` is. It is useful when axis has an ordinal scale.
* |---1---|---2---|---3---|---4---|.
*
* @param {boolean} [margin=false]
* If margin is true. Coord extent is start at the position of first tick and end
* at the position of last tick.
* @return {Array
.<number>
}
* @return {Array}
*/
getBandsCoords
:
function
(
margin
)
{
var
coordExtent
=
this
.
_coordExtent
;
var
extent
=
this
.
scale
.
getExtent
();
var
coords
=
[];
var
len
=
extent
[
1
]
-
extent
[
0
]
+
1
;
var
startCoord
=
coordExtent
[
0
];
var
endCoord
=
coordExtent
[
1
];
var
size
=
endCoord
-
startCoord
;
if
(
margin
)
{
var
marginSize
=
size
/
(
len
*
2
-
2
);
startCoord
-=
marginSize
;
size
+=
marginSize
*
2
;
}
for
(
var
i
=
0
;
i
<=
len
;
i
++
)
{
coords
.
push
(
size
*
i
/
len
+
startCoord
);
getBands
:
function
()
{
var
extent
=
this
.
_extent
;
var
bands
=
[];
var
len
=
this
.
scale
.
getExtentSize
()
+
1
;
var
start
=
extent
[
0
];
var
end
=
extent
[
1
];
var
size
=
end
-
start
;
for
(
var
i
=
1
;
i
<=
len
;
i
++
)
{
bands
.
push
([
size
*
(
i
-
1
)
/
len
+
start
,
size
*
i
/
len
+
start
]);
}
return
coor
ds
;
return
ban
ds
;
},
/**
* Get width of band
* @param {boolean} margin
* @return {number}
*/
getBandWidth
:
function
(
margin
)
{
var
coordExtent
=
this
.
_coordE
xtent
;
getBandWidth
:
function
()
{
var
axisExtent
=
this
.
_e
xtent
;
var
extent
=
this
.
scale
.
getExtent
();
var
len
=
extent
[
1
]
-
extent
[
0
]
+
1
;
var
size
=
coordExtent
[
1
]
-
coordExtent
[
0
];
if
(
margin
)
{
size
+=
size
/
(
len
-
1
);
}
var
size
=
axisExtent
[
1
]
-
axisExtent
[
0
];
return
Math
.
abs
(
size
)
/
len
;
}
};
...
...
src/coord/cartesian/Axis2D.js
浏览文件 @
69764d37
define
(
function
(
require
)
{
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
Axis
=
require
(
'
./Axis
'
);
var
Axis
=
require
(
'
.
.
/Axis
'
);
/**
* Extend axis 2d
...
...
@@ -33,11 +33,6 @@ define(function (require) {
* - 'right'
*/
this
.
position
=
position
||
'
bottom
'
;
/**
* @type {boolean}
*/
this
.
boundaryGap
=
false
;
};
Axis2D
.
prototype
=
{
...
...
@@ -47,7 +42,11 @@ define(function (require) {
isHorizontal
:
function
()
{
var
position
=
this
.
position
;
return
position
===
'
top
'
||
position
===
'
bottom
'
;
}
},
dataToCoord
:
Axis
.
prototype
.
mapData
,
coordToData
:
Axis
.
prototype
.
unmapData
};
zrUtil
.
inherits
(
Axis2D
,
Axis
);
...
...
src/coord/cartesian/Cartesian.js
浏览文件 @
69764d37
...
...
@@ -8,7 +8,6 @@ define(function (require) {
'
use strict
'
;
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
Axis
=
require
(
'
./Axis
'
);
function
dimAxisMapper
(
dim
)
{
return
this
.
_axes
[
dim
];
...
...
@@ -27,11 +26,6 @@ define(function (require) {
* @type {string}
*/
this
.
name
=
name
||
''
;
/**
* Series using this cartesian coordinate system
* @type {Array.<Object>}
*/
this
.
series
=
[];
};
Cartesian
.
prototype
=
{
...
...
@@ -70,19 +64,6 @@ define(function (require) {
);
},
/**
* Create a basic axis
* @param {number|string} dim
* @return {module:echarts/coord/Cartesian.Axis}
*/
createAxis
:
function
(
dim
,
scale
,
coordExtent
)
{
var
axis
=
new
Axis
(
dim
,
scale
,
coordExtent
);
this
.
addAxis
(
axis
);
return
axis
;
},
/**
* Add axis
* @param {module:echarts/coord/Cartesian.Axis}
...
...
src/coord/cartesian/Cartesian2D.js
浏览文件 @
69764d37
...
...
@@ -22,25 +22,17 @@ define(function(require) {
* `[[10, 10], [20, 20], [30, 30]]`
*/
dataToCoords
:
function
(
data
)
{
return
data
.
map
(
this
.
dataToCoord
,
this
);
},
dataToCoord
:
function
(
dataItem
)
{
var
xAxis
=
this
.
getAxis
(
'
x
'
);
var
yAxis
=
this
.
getAxis
(
'
y
'
);
var
xIndex
=
xAxis
.
isHorizontal
()
?
0
:
1
;
// If y axis is category axis
var
categoryAxis
=
this
.
getAxesByScale
(
'
ordinal
'
)[
0
];
var
swapAxis
=
categoryAxis
&&
categoryAxis
.
dim
===
'
y
'
;
var
x
=
dataItem
.
getX
();
var
y
=
categoryAxis
?
dataItem
.
getValue
()
:
dataItem
.
getY
();
return
data
.
map
(
function
(
dataItem
)
{
var
coord
=
[];
coord
[
xIndex
]
=
xAxis
.
dataToCoord
(
swapAxis
?
y
:
x
);
coord
[
1
-
xIndex
]
=
yAxis
.
dataToCoord
(
swapAxis
?
x
:
y
);
coord
[
xIndex
]
=
xAxis
.
dataToCoord
(
dataItem
.
getX
());
coord
[
1
-
xIndex
]
=
yAxis
.
dataToCoord
(
dataItem
.
getY
());
return
coord
;
},
this
);
}
};
...
...
src/coord/cartesian/Grid.js
浏览文件 @
69764d37
...
...
@@ -134,18 +134,9 @@ define(function(require, factory) {
}
axis
.
otherCoord
=
otherCoord
;
// Category axis with boundary gap. Which label and points are on the center of bands
// Insead of on the tick
if
(
axis
.
boundaryGap
&&
axis
.
type
===
'
category
'
)
{
var
size
=
extent
[
1
]
-
extent
[
0
];
var
len
=
axis
.
scale
.
getTicks
().
length
;
var
margin
=
size
/
len
/
2
;
extent
[
0
]
+=
margin
;
extent
[
1
]
-=
margin
;
}
var
start
=
axis
.
isHorizontal
()
?
0
:
1
;
axis
.
set
Coord
Extent
(
extent
[
start
],
extent
[
1
-
start
]);
axis
.
setExtent
(
extent
[
start
],
extent
[
1
-
start
]);
});
},
...
...
@@ -199,7 +190,7 @@ define(function(require, factory) {
xAxisModel
.
get
(
'
type
'
),
xAxisPosition
);
axisX
.
boundaryGap
=
xAxisModel
.
get
(
'
boundaryGap
'
);
axisX
.
onBand
=
xAxisModel
.
get
(
'
boundaryGap
'
);
axisX
.
inverse
=
xAxisModel
.
get
(
'
inverse
'
);
// Inject axis into axisModel
...
...
@@ -226,7 +217,7 @@ define(function(require, factory) {
yAxisModel
.
get
(
'
type
'
),
yAxisModel
.
get
(
'
position
'
)
);
axisY
.
boundaryGap
=
yAxisModel
.
get
(
'
boundaryGap
'
);
axisY
.
onBand
=
yAxisModel
.
get
(
'
boundaryGap
'
);
axisY
.
inverse
=
yAxisModel
.
get
(
'
inverse
'
);
yAxisModel
.
axis
=
axisY
;
...
...
src/data/List.js
浏览文件 @
69764d37
...
...
@@ -29,120 +29,88 @@ define(function(require) {
/**
* @name echarts/data/List~Entry
* @extends {module:echarts/model/Model}
*
* @param {Object} option
* @param {module:echarts/model/Model} parentModel
* @param {number} dataIndex
* @param {Array.<string>} [independentVar=['x']]
* @param {Array.<string>} [dependentVar='y']
*/
var
Entry
=
Model
.
extend
({
layout
:
null
,
dimension
:
1
,
init
:
function
(
option
,
parentModel
,
dataIndex
)
{
/**
* @type {string}
* @memeberOf module:echarts/data/List~Entry
* @public
* @type {number}
* @protected
*/
this
.
name
=
option
.
name
||
''
;
this
.
option
=
option
;
xIndex
:
0
,
/**
* @type {number|Array}
* @memeberOf module:echarts/data/List~Entry
* @private
* @type {number}
* @protected
*/
this
.
_value
=
option
.
value
==
null
?
option
:
option
.
value
yIndex
:
1
,
/**
* @private
* @readOnly
* @type {number}
* @protected
*/
this
.
dataIndex
=
dataIndex
||
0
;
},
zIndex
:
-
1
,
/**
* @return {number}
* @type {number}
* @protected
*/
getX
:
function
()
{
// Use idx as x if data is 1d
// Usually when xAxis is category axis
return
this
.
dimension
===
1
?
this
.
dataIndex
:
this
.
_value
[
0
];
},
valueIndex
:
1
,
/**
* @param {number} x
*/
setX
:
function
(
x
)
{
if
(
this
.
dimension
>
1
)
{
this
.
_value
[
0
]
=
x
;
}
},
init
:
function
(
option
,
parentModel
,
dataIndex
,
independentVar
,
dependentVar
)
{
/**
* @return {number}
* @type {string}
* @memeberOf module:echarts/data/List~Entry
* @public
*/
getY
:
function
()
{
if
(
this
.
dimension
>
1
)
{
return
this
.
_value
[
1
];
this
.
name
=
option
.
name
||
''
;
this
.
option
=
option
;
var
value
=
option
.
value
==
null
?
option
:
option
.
value
;
if
(
typeof
value
===
'
number
'
)
{
value
=
[
dataIndex
,
value
];
}
},
/**
* @param {number} y
*/
setY
:
function
(
y
)
{
if
(
this
.
dimension
>
1
)
{
this
.
_value
[
1
]
=
y
;
if
(
dependentVar
)
{
for
(
var
i
=
0
;
i
<
dependentVar
.
length
;
i
++
)
{
this
[
dependentVar
[
i
]
+
'
Index
'
]
=
i
;
}
},
this
.
valueIndex
=
value
.
length
-
1
;
/**
* @return {number}
*/
getZ
:
function
()
{
if
(
this
.
dimension
>
2
)
{
return
this
.
_value
[
2
];
this
[
independentVar
+
'
Index
'
]
=
this
.
valueIndex
;
}
},
/**
* @param {number} z
* @type {Array.<number>}
* @memeberOf module:echarts/data/List~Entry
* @private
*/
setZ
:
function
(
z
)
{
if
(
this
.
dimension
>
2
)
{
this
.
_value
[
2
]
=
z
;
}
},
this
.
_value
=
value
;
/**
* @return {number}
* @private
* @readOnly
*/
getValue
:
function
()
{
var
value
;
// PENDING
// Value is a single number if data is 1d
if
(
this
.
dimension
===
1
)
{
value
=
this
.
_value
;
}
else
{
value
=
this
.
_value
[
this
.
dimension
];
}
if
(
value
===
'
-
'
)
{
value
=
null
;
}
return
value
;
this
.
dataIndex
=
dataIndex
;
},
/**
* @
param {number} value
* @
return {number}
*/
setValue
:
function
(
value
)
{
if
(
this
.
dimension
===
1
)
{
this
.
_value
=
value
;
}
else
{
this
.
_value
[
this
.
dimension
]
=
value
getStackedValue
:
function
()
{
if
(
this
.
dimension
!==
1
)
{
// Only 1d value support stack
return
this
.
getValue
();
}
},
...
...
@@ -151,22 +119,33 @@ define(function(require) {
this
.
option
,
this
.
parentModel
,
this
.
dataIndex
);
entry
.
name
=
this
.
name
;
entry
.
dimension
=
this
.
dimension
;
entry
.
xIndex
=
this
.
xIndex
;
entry
.
yIndex
=
this
.
yIndex
;
entry
.
zIndex
=
this
.
zIndex
;
entry
.
valueIndex
=
this
.
valueIndex
;
return
entry
;
}
});
function
List
()
{
zrUtil
.
each
([
'
x
'
,
'
y
'
,
'
z
'
,
'
value
'
],
function
(
dim
)
{
var
capitalized
=
dim
[
0
].
toUpperCase
()
+
dim
.
substr
(
1
);
var
indexKey
=
dim
+
'
Index
'
;
Entry
.
prototype
[
'
get
'
+
capitalized
]
=
function
()
{
var
index
=
this
[
indexKey
];
if
(
index
>=
0
)
{
return
this
.
_value
[
index
];
}
}
Entry
.
prototype
[
'
set
'
+
capitalized
]
=
function
(
val
)
{
var
index
=
this
[
indexKey
];
if
(
index
>=
0
)
{
this
.
_value
[
indexKey
]
=
val
;
}
}
});
function
List
()
{
this
.
elements
=
[];
// Depth and properties is useful in nested Array.
// For example in eventRiver, data structure is a nested 2d array as following
// [{evolution: []}, {evolution: []}]
// In this situation. depth should be 2 and properties should be ['evolution']
this
.
depth
=
1
;
this
.
properties
=
[];
}
List
.
prototype
=
{
...
...
@@ -177,18 +156,12 @@ define(function(require) {
each
:
function
(
cb
,
context
)
{
context
=
context
||
this
;
if
(
this
.
depth
>
1
)
{
createArrayIterWithDepth
(
this
.
depth
,
this
.
properties
,
cb
,
context
,
'
each
'
)(
this
.
elements
,
0
);
}
else
{
zrUtil
.
each
(
this
.
elements
,
cb
,
context
);
}
},
/**
* Data mapping, returned array is flatten
* PENDING
*/
map
:
function
(
cb
,
context
)
{
var
ret
=
[];
...
...
@@ -198,36 +171,12 @@ define(function(require) {
return
ret
;
},
/**
* In-place filter
*/
filterInPlace
:
function
(
cb
,
context
)
{
filter
:
function
(
cb
,
context
)
{
var
list
=
new
List
();
context
=
context
||
this
;
if
(
this
.
depth
>
1
)
{
createArrayIterWithDepth
(
this
.
depth
,
this
.
properties
,
cb
,
context
,
'
filter
'
)(
this
.
elements
,
0
);
}
else
{
this
.
elements
=
zrUtil
.
filter
(
this
.
elements
,
cb
,
context
);
}
list
.
elements
=
zrUtil
.
filter
(
this
.
elements
,
cb
,
context
);
},
/**
* In-place map
*/
// mapInPlace: function (cb, context) {
// context = context || this;
// if (this.depth > 1) {
// createArrayIterWithDepth(
// this.depth, this.properties, cb, context, 'map'
// )(this.elements, 0);
// }
// else {
// this.elements = zrUtil.map(this.elements, cb, context);
// }
// },
/**
* @return {module:echarts/data/List~Entry}
*/
...
...
@@ -285,16 +234,41 @@ define(function(require) {
};
});
List
.
fromArray
=
function
(
data
,
dimension
,
parentModel
)
{
List
.
fromArray
=
function
(
data
,
seriesModel
,
ecModel
)
{
var
xAxisModel
=
ecModel
.
getComponent
(
'
xAxis
'
,
seriesModel
.
get
(
'
xAxisIndex
'
));
var
yAxisModel
=
ecModel
.
getComponent
(
'
yAxis
'
,
seriesModel
.
get
(
'
yAxisIndex
'
));
var
independentVar
;
var
dependentVar
;
// if (xAxisModel.get('type') === 'category') {
// independentVar = ['x'];
// dependentVar = 'y';
// }
// else if (yAxisModel.get('type') === 'category') {
// independentVar = ['y'];
// dependentVar = 'x';
// }
// else {
// var dim = data[0] && data[0].length;
// if (dim === 2) {
// independentVar = ['x'];
// dependentVar = 'y';
// }
// else if (dim === 3) {
// independentVar = ['x', 'y'];
// dependentVar = 'z';
// }
// }
var
list
=
new
List
();
// Normalize data
list
.
elements
=
zrUtil
.
map
(
data
,
function
(
dataItem
,
index
)
{
var
entry
=
new
Entry
(
dataItem
,
parentModel
,
index
);
var
entry
=
new
Entry
(
dataItem
,
seriesModel
,
index
,
independentVar
,
dependentVar
);
// TODO
if
(
!
dataItem
.
name
)
{
entry
.
name
=
index
;
}
entry
.
dimension
=
dimension
||
1
;
return
entry
;
});
return
list
;
...
...
src/echarts.js
浏览文件 @
69764d37
/**
* TODO processor的优先级
* restore
* setTheme
* stack
* axis position 统一处理
*/
define
(
function
(
require
)
{
...
...
@@ -155,6 +155,8 @@ define(function (require) {
},
updateImmediately
:
function
()
{
// console.time('update');
var
ecModel
=
this
.
_model
;
ecModel
.
restore
();
...
...
@@ -172,6 +174,8 @@ define(function (require) {
this
.
_doRender
(
ecModel
);
this
.
_needsUpdate
=
false
;
// console.timeEnd('update');
},
resize
:
function
()
{
...
...
@@ -325,16 +329,24 @@ define(function (require) {
},
this
);
// Remove groups of charts
zrUtil
.
each
(
this
.
_chartsList
,
function
(
chart
)
{
this
.
_zr
.
remove
(
chart
.
group
)
;
chart
.
__keepAlive
=
false
;
},
this
);
// Render all charts
ecModel
.
eachSeries
(
function
(
seriesModel
,
idx
)
{
var
id
=
getSeriesId
(
seriesModel
.
option
,
idx
);
var
chart
=
this
.
_chartsMap
[
id
];
chart
.
__keepAlive
=
true
;
chart
.
render
(
seriesModel
,
ecModel
,
api
);
this
.
_zr
.
add
(
chart
.
group
);
},
this
);
// Remove groups of charts
zrUtil
.
each
(
this
.
_chartsList
,
function
(
chart
)
{
if
(
!
chart
.
__keepAlive
)
{
this
.
_zr
.
remove
(
chart
.
group
);
chart
.
remove
();
}
},
this
);
},
dispose
:
function
()
{
...
...
src/scale/Ordinal.js
浏览文件 @
69764d37
...
...
@@ -93,6 +93,13 @@ define(function (require) {
return
ticks
;
},
/**
* @return {number}
*/
getExtentSize
:
function
()
{
return
this
.
_extent
[
1
]
-
this
.
_extent
[
0
];
},
/**
* Get item on rank n
*/
...
...
src/view/Chart.js
浏览文件 @
69764d37
...
...
@@ -20,6 +20,8 @@ define(function (require) {
render
:
function
()
{},
remove
:
function
()
{},
dispose
:
function
()
{}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录