Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
e8b724a3
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,发现更多精彩内容 >>
提交
e8b724a3
编写于
10月 14, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Map data statistic
上级
c7c9d570
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
91 addition
and
15 deletion
+91
-15
src/chart/map/MapSeries.js
src/chart/map/MapSeries.js
+36
-4
src/chart/map/mapDataStatistic.js
src/chart/map/mapDataStatistic.js
+23
-6
src/coord/geo/Geo.js
src/coord/geo/Geo.js
+7
-1
src/coord/geo/geoCreator.js
src/coord/geo/geoCreator.js
+15
-1
src/data/List.js
src/data/List.js
+10
-3
未找到文件。
src/chart/map/MapSeries.js
浏览文件 @
e8b724a3
define
(
function
(
require
)
{
// var SeriesModel = require('../../model/Series');
var
List
=
require
(
'
../../data/List
'
);
return
require
(
'
../../echarts
'
).
extendSeriesModel
({
var
echarts
=
require
(
'
../../echarts
'
);
function
fillData
(
dataOpt
,
geoJson
)
{
var
dataNameMap
=
{};
var
features
=
geoJson
.
features
;
for
(
var
i
=
0
;
i
<
dataOpt
.
length
;
i
++
)
{
dataNameMap
[
dataOpt
[
i
].
name
]
=
dataOpt
[
i
];
}
for
(
var
i
=
0
;
i
<
features
.
length
;
i
++
)
{
var
name
=
features
[
i
].
properties
.
name
;
if
(
!
dataNameMap
[
name
])
{
dataOpt
.
push
({
value
:
NaN
,
name
:
name
});
}
}
return
dataOpt
;
}
return
echarts
.
extendSeriesModel
({
type
:
'
series.map
'
,
...
...
@@ -13,7 +32,20 @@ define(function (require) {
name
:
'
value
'
}],
this
);
list
.
initData
(
option
.
data
);
var
geoJson
=
echarts
.
getMap
(
option
.
mapType
);
var
dataOpt
=
option
.
data
||
[];
// https://jsperf.com/try-catch-performance-overhead
if
(
geoJson
)
{
try
{
dataOpt
=
fillData
(
dataOpt
,
geoJson
);
}
catch
(
e
)
{
throw
'
Invalid geoJson format
\n
'
+
e
;
}
}
list
.
initData
(
dataOpt
);
return
list
;
},
...
...
src/chart/map/mapDataStatistic.js
浏览文件 @
e8b724a3
...
...
@@ -2,6 +2,8 @@ define(function (require) {
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
List
=
require
(
'
../../data/List
'
);
// FIXME 公用?
/**
* @param {Array.<module:echarts/data/List>} datas
...
...
@@ -9,15 +11,30 @@ define(function (require) {
* @inner
*/
function
dataStatistics
(
datas
,
statisticsType
)
{
var
len
=
datas
.
length
;
return
datas
[
0
].
map
([
'
value
'
],
function
(
value
,
idx
)
{
for
(
var
i
=
1
;
i
<
len
;
i
++
)
{
value
+=
datas
[
i
].
get
(
'
value
'
,
idx
);
var
dataNameMap
=
{};
var
dims
=
[
'
value
'
];
for
(
var
i
=
0
;
i
<
datas
.
length
;
i
++
)
{
datas
[
i
].
each
(
dims
,
function
(
value
,
idx
)
{
var
name
=
datas
[
i
].
getName
(
idx
);
dataNameMap
[
name
]
=
dataNameMap
[
name
]
||
[];
if
(
!
isNaN
(
value
))
{
dataNameMap
[
name
].
push
(
value
);
}
});
}
return
datas
[
0
].
map
(
dims
,
function
(
value
,
idx
)
{
var
name
=
datas
[
0
].
getName
(
idx
);
var
sum
=
0
;
var
len
=
dataNameMap
[
name
].
length
;
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
sum
+=
dataNameMap
[
name
][
i
];
}
if
(
statisticsType
===
'
average
'
)
{
value
/=
len
;
sum
/=
len
;
}
return
value
;
return
sum
;
});
}
...
...
src/coord/geo/Geo.js
浏览文件 @
e8b724a3
...
...
@@ -12,7 +12,13 @@ define(function (require) {
this
.
name
=
name
;
this
.
regions
=
geoJson
?
parseGeoJson
(
geoJson
)
:
[];
// https://jsperf.com/try-catch-performance-overhead
try
{
this
.
regions
=
geoJson
?
parseGeoJson
(
geoJson
)
:
[];
}
catch
(
e
)
{
throw
'
Invalid geoJson format
\n
'
+
e
;
}
/**
* @param {Array.<string>}
...
...
src/coord/geo/geoCreator.js
浏览文件 @
e8b724a3
...
...
@@ -5,7 +5,6 @@ define(function (require) {
var
Geo
=
require
(
'
./Geo
'
);
var
numberUtil
=
require
(
'
../../util/number
'
);
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
mapDataStores
=
{};
...
...
@@ -99,15 +98,30 @@ define(function (require) {
return
geoList
;
},
/**
* @param {string} mapName
* @param {Object} geoJson
*/
registerMap
:
function
(
mapName
,
geoJson
)
{
mapDataStores
[
mapName
]
=
geoJson
;
},
/**
* @param {string} mapName
* @return {Object}
*/
getMap
:
function
(
mapName
)
{
return
mapDataStores
[
mapName
];
}
};
// Inject methods into echarts
var
echarts
=
require
(
'
../../echarts
'
);
echarts
.
registerMap
=
geoCreator
.
registerMap
;
echarts
.
getMap
=
geoCreator
.
getMap
;
// TODO
echarts
.
loadMap
=
function
()
{
...
...
src/data/List.js
浏览文件 @
e8b724a3
...
...
@@ -657,20 +657,27 @@ define(function (require) {
* It will create a temporary model if value on idx is not an option.
*
* @param {number} idx
* @param {boolean} [createNew=false]
*/
// FIXME Model proxy ?
listProto
.
getItemModel
=
function
(
idx
)
{
listProto
.
getItemModel
=
function
(
idx
,
createNew
)
{
var
storage
=
this
.
_storage
;
var
optionModelIndices
=
storage
.
$optionModelIndices
;
var
modelIndex
=
optionModelIndices
&&
optionModelIndices
[
this
.
indices
[
idx
]];
var
model
=
this
.
_optionModels
[
modelIndex
];
var
hostModel
=
this
.
hostModel
;
if
(
!
model
)
{
// Use a temporary model proxy if value on idx is not an option.
// FIXME Create a new one may cause memory leak
model
=
temporaryModel
;
model
.
parentModel
=
this
.
hostModel
;
if
(
createNew
)
{
model
=
new
Model
(
null
,
hostModel
);
}
else
{
model
=
temporaryModel
;
model
.
parentModel
=
hostModel
;
}
}
return
model
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录