Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alon@wen
echarts
提交
536f61f4
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,发现更多精彩内容 >>
提交
536f61f4
编写于
9月 01, 2015
作者:
P
pah100
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
save / restore data, legend problem
上级
77231023
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
266 addition
and
58 deletion
+266
-58
src/chart/line/LineSeries.js
src/chart/line/LineSeries.js
+2
-0
src/chart/scatter/ScatterSeries.js
src/chart/scatter/ScatterSeries.js
+2
-0
src/component/dataZoom/DataZoomView.js
src/component/dataZoom/DataZoomView.js
+4
-5
src/component/dataZoom/dataZoomAction.js
src/component/dataZoom/dataZoomAction.js
+9
-1
src/component/dataZoom/dataZoomProcessor.js
src/component/dataZoom/dataZoomProcessor.js
+4
-2
src/component/dataZoom/helper.js
src/component/dataZoom/helper.js
+77
-0
src/component/legend/LegendView.js
src/component/legend/LegendView.js
+1
-1
src/echarts.js
src/echarts.js
+1
-3
src/model/Global.js
src/model/Global.js
+28
-30
src/model/Model.js
src/model/Model.js
+9
-3
src/model/Series.js
src/model/Series.js
+3
-11
src/view/Chart.js
src/view/Chart.js
+7
-0
src/view/Component.js
src/view/Component.js
+7
-0
test/ut/all.js
test/ut/all.js
+2
-1
test/ut/core/utHelper.js
test/ut/core/utHelper.js
+22
-0
test/ut/lib/jasmine-2.3.4/jasmine.css
test/ut/lib/jasmine-2.3.4/jasmine.css
+1
-1
test/ut/spec/dataZoom/helper.js
test/ut/spec/dataZoom/helper.js
+87
-0
未找到文件。
src/chart/line/LineSeries.js
浏览文件 @
536f61f4
...
...
@@ -9,6 +9,8 @@ define(function(require) {
type
:
'
series.line
'
,
dependencies
:
[
'
xAxis
'
,
'
yAxis
'
],
getInitialData
:
function
(
option
,
ecModel
)
{
return
List
.
fromArray
(
option
.
data
,
this
,
ecModel
);
},
...
...
src/chart/scatter/ScatterSeries.js
浏览文件 @
536f61f4
...
...
@@ -9,6 +9,8 @@ define(function (require) {
type
:
'
series.scatter
'
,
dependencies
:
[
'
xAxis
'
,
'
yAxis
'
],
getInitialData
:
function
(
option
,
ecModel
)
{
return
List
.
fromArray
(
option
.
data
,
this
,
ecModel
);
},
...
...
src/component/dataZoom/DataZoomView.js
浏览文件 @
536f61f4
...
...
@@ -3,7 +3,6 @@ define(function (require) {
var
echarts
=
require
(
'
../../echarts
'
);
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
helper
=
require
(
'
./helper
'
);
var
unique
=
require
(
'
../../util/unique
'
);
var
retrieveValue
=
helper
.
retrieveValue
;
// Constants
...
...
@@ -16,7 +15,6 @@ define(function (require) {
init
:
function
(
echarts
)
{
this
.
_location
;
this
.
_uid
=
unique
.
getUID
(
'
dataZoomView
'
);
},
render
:
function
(
dataZoomModel
,
ecModel
,
api
,
event
)
{
...
...
@@ -29,7 +27,7 @@ define(function (require) {
this
.
_api
=
api
;
this
.
_orient
=
dataZoomModel
.
get
(
'
orient
'
);
if
(
!
event
||
event
.
type
!==
'
dataZoom
'
||
event
.
from
!==
this
.
_
uid
)
{
if
(
!
event
||
event
.
type
!==
'
dataZoom
'
||
event
.
from
!==
this
.
uid
)
{
this
.
group
.
clear
();
if
(
this
.
dataZoomModel
.
get
(
'
show
'
)
===
false
)
{
...
...
@@ -300,8 +298,9 @@ define(function (require) {
this
.
_api
.
dispatch
({
type
:
'
dataZoom
'
,
from
:
this
.
_uid
,
param
:
this
.
_normalizeToRange
()
from
:
this
.
uid
,
param
:
this
.
_normalizeToRange
(),
targetModel
:
this
.
_dataZoomModel
});
// FIXME
...
...
src/component/dataZoom/dataZoomAction.js
浏览文件 @
536f61f4
...
...
@@ -8,7 +8,8 @@ define(function(require) {
var
echarts
=
require
(
'
../../echarts
'
);
var
helper
=
require
(
'
./helper
'
);
echarts
.
registerAction
(
function
(
event
,
ecModel
)
{
echarts
.
registerAction
(
'
dataZoom
'
,
function
(
event
,
ecModel
)
{
var
sourceDataZoomModel
=
event
.
targetModel
;
ecModel
.
eachComponent
(
'
dataZoom
'
,
zrUtil
.
curry
(
processSingleDataZoom
,
event
,
ecModel
));
});
...
...
@@ -21,4 +22,11 @@ define(function(require) {
});
}
function
processSingleAxis
(
ecModel
,
dataZoomModel
,
dimNames
,
axisIndex
)
{
}
function
isSharingAxis
(
dataZoomModel0
,
dataZoomModel1
)
{
}
});
\ No newline at end of file
src/component/dataZoom/dataZoomProcessor.js
浏览文件 @
536f61f4
...
...
@@ -62,11 +62,13 @@ define(function (require) {
// 这里仅仅处理了list类型
var
seriesData
=
seriesModel
.
getData
();
seriesModel
.
setData
(
seriesData
[
'
filter
'
+
dimNames
.
dim
.
toUpperCase
()](
start
,
end
)
seriesData
[
'
filter
'
+
dimNames
.
dim
.
toUpperCase
()](
function
(
value
)
{
return
value
>=
start
&&
value
<=
end
;
})
);
// FIXME
// 对于数值轴,还要考虑log等情况
// 对于数值轴,还要考虑log等情况
.
// FIXME
// 对于时间河流图,还要考虑是否须整块移除。
});
...
...
src/component/dataZoom/helper.js
浏览文件 @
536f61f4
...
...
@@ -48,5 +48,82 @@ define(function(require) {
return
zrUtil
.
isArray
(
value
)
?
value
:
(
value
==
null
?
[]
:
[
value
]);
};
/**
* @public
*/
helper
.
findLinkSet
=
function
(
forEachModel
,
axisIndicesGetter
,
sourceModel
)
{
var
result
=
{
models
:
[],
dims
:
{}};
var
dimRecords
=
{};
helper
.
eachAxisDim
(
function
(
dimNames
)
{
result
.
dims
[
dimNames
.
dim
]
=
[];
dimRecords
[
dimNames
.
dim
]
=
[];
});
if
(
!
sourceModel
)
{
return
result
;
}
absorb
(
sourceModel
);
var
existsLink
;
do
{
existsLink
=
false
;
forEachModel
(
processSingleModel
);
}
while
(
existsLink
);
wrapUpResult
();
return
result
;
function
processSingleModel
(
model
)
{
if
(
!
isModelAbsorded
(
model
)
&&
isLink
(
model
))
{
absorb
(
model
);
existsLink
=
true
;
}
}
function
isModelAbsorded
(
model
)
{
return
zrUtil
.
indexOf
(
result
.
models
,
model
)
>=
0
;
}
function
isLink
(
model
)
{
var
hasLink
=
false
;
helper
.
eachAxisDim
(
function
(
dimNames
)
{
var
axisIndices
=
axisIndicesGetter
(
model
,
dimNames
);
var
singleDimSet
=
dimRecords
[
dimNames
.
dim
];
for
(
var
i
=
0
,
len
=
axisIndices
.
length
;
i
<
len
;
i
++
)
{
if
(
singleDimSet
[
axisIndices
[
i
]])
{
hasLink
=
true
;
return
;
}
}
});
return
hasLink
;
}
function
absorb
(
model
)
{
result
.
models
.
push
(
model
);
helper
.
eachAxisDim
(
function
(
dimNames
)
{
var
axisIndices
=
axisIndicesGetter
(
model
,
dimNames
);
var
singleDimSet
=
dimRecords
[
dimNames
.
dim
];
for
(
var
i
=
0
,
len
=
axisIndices
.
length
;
i
<
len
;
i
++
)
{
singleDimSet
[
axisIndices
[
i
]]
=
true
;
}
});
}
function
wrapUpResult
()
{
helper
.
eachAxisDim
(
function
(
dimNames
)
{
var
dimRecord
=
dimRecords
[
dimNames
.
dim
];
for
(
var
i
=
0
;
i
<
dimRecord
.
length
;
i
++
)
{
if
(
dimRecord
[
i
])
{
result
.
dims
[
dimNames
.
dim
].
push
(
i
);
}
}
});
}
};
return
helper
;
});
\ No newline at end of file
src/component/legend/LegendView.js
浏览文件 @
536f61f4
...
...
@@ -34,7 +34,7 @@ define(function (require) {
legendModel
.
getData
().
each
(
function
(
dataItem
)
{
var
seriesName
=
dataItem
.
name
;
var
seriesModel
=
ecModel
.
getSeriesByName
(
seriesName
);
var
seriesModel
=
ecModel
.
getSeriesByName
(
seriesName
,
true
);
var
color
=
legendModel
.
isSelected
(
seriesName
)
?
seriesModel
.
getVisual
(
'
color
'
)
:
'
#ccc
'
;
...
...
src/echarts.js
浏览文件 @
536f61f4
...
...
@@ -159,9 +159,7 @@ define(function (require) {
var
ecModel
=
this
.
_model
;
ecModel
.
restore
();
ecModel
.
save
();
ecModel
.
restoreData
();
this
.
_processData
(
ecModel
);
...
...
src/model/Global.js
浏览文件 @
536f61f4
...
...
@@ -48,6 +48,12 @@ define(function (require) {
*/
this
.
_componentsMap
=
{};
/**
* @type {Object.<string, module:echarts/model/Model>}
* @private
*/
this
.
_componentsMapBeforeProcessing
=
{};
/**
* @type {module:echarts/model/Model}
* @private
...
...
@@ -149,6 +155,11 @@ define(function (require) {
}
}
},
this
);
// Backup data
zrUtil
.
each
(
componentsMap
,
function
(
components
,
componentType
)
{
this
.
_componentsMapBeforeProcessing
[
componentType
]
=
components
.
slice
();
},
this
);
},
/**
...
...
@@ -179,10 +190,13 @@ define(function (require) {
/**
* @param {string} name
* @param {boolean} beforeProcessing
* @return {module:echarts/model/Series}
*/
getSeriesByName
:
function
(
name
)
{
var
series
=
this
.
_componentsMap
.
series
;
getSeriesByName
:
function
(
name
,
beforeProcessing
)
{
var
series
=
beforeProcessing
?
this
.
_componentsMapBeforeProcessing
.
series
:
this
.
_componentsMap
.
series
;
for
(
var
i
=
0
,
len
=
series
.
length
;
i
<
len
;
i
++
)
{
// name should be unique.
if
(
series
[
i
].
name
===
name
)
{
...
...
@@ -238,36 +252,20 @@ define(function (require) {
);
},
save
:
function
()
{
var
seriesList
=
this
.
_componentsMap
.
series
;
this
.
_stack
.
push
({
series
:
seriesList
.
slice
()
});
var
components
=
this
.
_components
;
var
i
;
for
(
i
=
0
;
i
<
components
.
length
;
i
++
)
{
components
[
i
].
save
();
}
for
(
i
=
0
;
i
<
seriesList
.
length
;
i
++
)
{
seriesList
[
i
].
save
();
}
},
restoreData
:
function
()
{
var
componentsMap
=
this
.
_componentsMap
;
var
componentTypes
=
[];
restore
:
function
(
)
{
if
(
this
.
_stack
.
length
)
{
this
.
_componentsMap
.
series
=
this
.
_stack
.
pop
().
series
;
}
zrUtil
.
each
(
this
.
_componentsMapBeforeProcessing
,
function
(
components
,
componentType
)
{
componentsMap
[
componentType
]
=
components
.
slice
();
componentTypes
.
push
(
componentType
)
;
}
);
var
seriesList
=
this
.
_componentsMap
.
series
;
var
components
=
this
.
_components
;
var
i
;
for
(
i
=
0
;
i
<
components
.
length
;
i
++
)
{
components
[
i
].
restore
();
}
for
(
i
=
0
;
i
<
seriesList
.
length
;
i
++
)
{
seriesList
[
i
].
restore
();
}
ComponentModel
.
topologicalTravel
(
componentTypes
,
function
(
componentType
,
dependencies
)
{
zrUtil
.
each
(
componentsMap
[
componentType
],
function
(
component
)
{
component
.
restoreData
();
});
});
},
/**
...
...
src/model/Model.js
浏览文件 @
536f61f4
...
...
@@ -4,6 +4,7 @@
define
(
function
(
require
)
{
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
unique
=
require
(
'
../util/unique
'
);
/**
* @alias module:echarts/model/Model
...
...
@@ -37,6 +38,13 @@ define(function (require) {
*/
this
.
dependentModels
=
dependentModels
;
/**
* @type {string}
* @public
* @readOnly
*/
this
.
uid
=
unique
.
getUID
(
'
model
'
);
this
.
init
.
apply
(
this
,
arguments
);
}
...
...
@@ -133,9 +141,7 @@ define(function (require) {
this
.
_visual
[
key
]
=
val
;
},
save
:
function
()
{},
restore
:
function
()
{},
restoreData
:
function
()
{},
// Pending
clone
:
function
()
{
...
...
src/model/Series.js
浏览文件 @
536f61f4
...
...
@@ -49,7 +49,7 @@ define(function(require) {
*/
this
.
_data
=
this
.
getInitialData
(
option
,
ecModel
);
this
.
_
stack
=
[]
;
this
.
_
dataBeforeProcessing
=
this
.
_data
.
clone
()
;
},
mergeDefaultAndTheme
:
function
(
option
,
ecModel
)
{
...
...
@@ -74,16 +74,8 @@ define(function(require) {
return
this
.
_data
;
},
save
:
function
()
{
this
.
_stack
.
push
({
data
:
this
.
_data
.
clone
()
});
},
restore
:
function
()
{
if
(
this
.
_stack
.
length
)
{
this
.
_data
=
this
.
_stack
.
pop
().
data
;
}
restoreData
:
function
()
{
this
.
_data
=
this
.
_dataBeforeProcessing
.
clone
();
}
});
...
...
src/view/Chart.js
浏览文件 @
536f61f4
...
...
@@ -2,6 +2,7 @@ define(function (require) {
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
Group
=
require
(
'
zrender/container/Group
'
);
var
unique
=
require
(
'
../util/unique
'
);
function
Chart
()
{
...
...
@@ -10,6 +11,12 @@ define(function (require) {
* @readOnly
*/
this
.
group
=
new
Group
();
/**
* @type {string}
* @readOnly
*/
this
.
uid
=
unique
.
getUID
(
'
viewChart
'
);
}
Chart
.
prototype
=
{
...
...
src/view/Component.js
浏览文件 @
536f61f4
...
...
@@ -2,6 +2,7 @@ define(function (require) {
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
Group
=
require
(
'
zrender/container/Group
'
);
var
unique
=
require
(
'
../util/unique
'
);
var
Component
=
function
()
{
/**
...
...
@@ -9,6 +10,12 @@ define(function (require) {
* @readOnly
*/
this
.
group
=
new
Group
();
/**
* @type {string}
* @readOnly
*/
this
.
uid
=
unique
.
getUID
(
'
viewComponent
'
);
};
Component
.
prototype
=
{
...
...
test/ut/all.js
浏览文件 @
536f61f4
document
.
write
(
'
<script src="ut/
spec/common/h
elper.js"><
\
/script>
'
);
document
.
write
(
'
<script src="ut/
core/utH
elper.js"><
\
/script>
'
);
// Specs ...
document
.
write
(
'
<script src="ut/spec/model/Component.js"><
\
/script>
'
);
document
.
write
(
'
<script src="ut/spec/dataZoom/helper.js"><
\
/script>
'
);
test/ut/
spec/common/h
elper.js
→
test/ut/
core/utH
elper.js
浏览文件 @
536f61f4
...
...
@@ -6,6 +6,8 @@
*/
var
helper
=
context
.
utHelper
=
{};
var
nativeSlice
=
Array
.
prototype
.
slice
;
/**
* @public
*/
...
...
@@ -40,6 +42,26 @@
||
document
.
documentElement
;
};
/**
* @public
*/
helper
.
curry
=
function
(
func
)
{
var
args
=
nativeSlice
.
call
(
arguments
,
1
);
return
function
()
{
return
func
.
apply
(
this
,
args
.
concat
(
nativeSlice
.
call
(
arguments
)));
};
};
/**
* @public
*/
helper
.
bind
=
function
(
func
,
context
)
{
var
args
=
nativeSlice
.
call
(
arguments
,
2
);
return
function
()
{
return
func
.
apply
(
context
,
args
.
concat
(
nativeSlice
.
call
(
arguments
)));
};
};
/**
* Load javascript script
*
...
...
test/ut/lib/jasmine-2.3.4/jasmine.css
浏览文件 @
536f61f4
...
...
@@ -53,6 +53,6 @@ body { overflow-y: scroll; }
.jasmine_html-reporter
.failures
.spec-detail
{
margin-bottom
:
28px
;
}
.jasmine_html-reporter
.failures
.spec-detail
.description
{
background-color
:
#ca3a11
;
}
.jasmine_html-reporter
.failures
.spec-detail
.description
a
{
color
:
white
;
}
.jasmine_html-reporter
.result-message
{
padding-top
:
14px
;
color
:
#333
;
white-space
:
pre
;
}
.jasmine_html-reporter
.result-message
{
padding-top
:
14px
;
color
:
#333
;
}
.jasmine_html-reporter
.result-message
span
.result
{
display
:
block
;
}
.jasmine_html-reporter
.stack-trace
{
margin
:
5px
0
0
0
;
max-height
:
224px
;
overflow
:
auto
;
line-height
:
18px
;
color
:
#666
;
border
:
1px
solid
#ddd
;
background
:
white
;
white-space
:
pre
;
}
test/ut/spec/dataZoom/helper.js
0 → 100755
浏览文件 @
536f61f4
describe
(
'
dataZoom#helper
'
,
function
()
{
var
utHelper
=
window
.
utHelper
;
var
helper
;
beforeAll
(
function
(
done
)
{
// jshint ignore:line
utHelper
.
resetPackageLoader
(
function
()
{
window
.
require
([
'
echarts/component/dataZoom/helper
'
],
function
(
h
)
{
helper
=
h
;
done
();
});
});
});
describe
(
'
findLinkSet
'
,
function
()
{
function
forEachModel
(
models
,
callback
)
{
for
(
var
i
=
0
;
i
<
models
.
length
;
i
++
)
{
callback
(
models
[
i
]);
}
}
function
axisIndicesGetter
(
model
,
dimNames
)
{
return
model
[
dimNames
.
axisIndex
];
}
it
(
'
findLinkSet_base
'
,
function
(
done
)
{
var
models
=
[
{
xAxisIndex
:
[
1
,
2
],
yAxisIndex
:
[
0
]},
{
xAxisIndex
:
[
3
],
yAxisIndex
:
[
1
]},
{
xAxisIndex
:
[
5
],
yAxisIndex
:
[]},
{
xAxisIndex
:
[
2
,
5
],
yAxisIndex
:
[]}
];
var
result
=
helper
.
findLinkSet
(
utHelper
.
curry
(
forEachModel
,
models
),
axisIndicesGetter
,
models
[
0
]
);
expect
(
result
).
toEqual
({
models
:
[
models
[
0
],
models
[
3
],
models
[
2
]],
dims
:
{
x
:
[
1
,
2
,
5
],
y
:
[
0
]}
});
done
();
});
it
(
'
findLinkSet_crossXY
'
,
function
(
done
)
{
var
models
=
[
{
xAxisIndex
:
[
1
,
2
],
yAxisIndex
:
[
0
]},
{
xAxisIndex
:
[
3
],
yAxisIndex
:
[
3
,
0
]},
{
xAxisIndex
:
[
6
,
3
],
yAxisIndex
:
[
9
]},
{
xAxisIndex
:
[
5
,
3
],
yAxisIndex
:
[]},
{
xAxisIndex
:
[
8
],
yAxisIndex
:
[
4
]}
];
var
result
=
helper
.
findLinkSet
(
utHelper
.
curry
(
forEachModel
,
models
),
axisIndicesGetter
,
models
[
0
]
);
expect
(
result
).
toEqual
({
models
:
[
models
[
0
],
models
[
1
],
models
[
2
],
models
[
3
]],
dims
:
{
x
:
[
1
,
2
,
3
,
5
,
6
],
y
:
[
0
,
3
,
9
]}
});
done
();
});
it
(
'
findLinkSet_emptySourceModel
'
,
function
(
done
)
{
var
models
=
[
{
xAxisIndex
:
[
1
,
2
],
yAxisIndex
:
[
0
]},
{
xAxisIndex
:
[
3
],
yAxisIndex
:
[
3
,
0
]},
{
xAxisIndex
:
[
6
,
3
],
yAxisIndex
:
[
9
]},
{
xAxisIndex
:
[
5
,
3
],
yAxisIndex
:
[]},
{
xAxisIndex
:
[
8
],
yAxisIndex
:
[
4
]}
];
var
result
=
helper
.
findLinkSet
(
utHelper
.
curry
(
forEachModel
,
models
),
axisIndicesGetter
);
expect
(
result
).
toEqual
({
models
:
[],
dims
:
{
x
:
[],
y
:
[]}
});
done
();
});
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录