Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
242f6d02
I
incubator-echarts
项目概览
x649585723
/
incubator-echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
242f6d02
编写于
2月 11, 2018
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #7629 (map should selectable on area that no data)
上级
463ea55a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
33 deletion
+47
-33
src/chart/map/MapSeries.js
src/chart/map/MapSeries.js
+23
-5
src/chart/pie/PieSeries.js
src/chart/pie/PieSeries.js
+18
-2
src/component/helper/selectableMixin.js
src/component/helper/selectableMixin.js
+3
-17
test/map.html
test/map.html
+3
-9
未找到文件。
src/chart/map/MapSeries.js
浏览文件 @
242f6d02
...
...
@@ -3,7 +3,8 @@ import createListSimply from '../helper/createListSimply';
import
SeriesModel
from
'
../../model/Series
'
;
import
{
encodeHTML
,
addCommas
}
from
'
../../util/format
'
;
import
dataSelectableMixin
from
'
../../component/helper/selectableMixin
'
;
// import geoCreator from '../../coord/geo/geoCreator';
import
{
retrieveRawAttr
}
from
'
../../data/helper/dataProvider
'
;
import
geoCreator
from
'
../../coord/geo/geoCreator
'
;
var
MapSeries
=
SeriesModel
.
extend
({
...
...
@@ -27,12 +28,12 @@ var MapSeries = SeriesModel.extend({
init
:
function
(
option
)
{
this
.
_fillOption
(
option
,
this
.
getMapType
());
//
this._fillOption(option, this.getMapType());
// this.option = option;
MapSeries
.
superApply
(
this
,
'
init
'
,
arguments
);
this
.
updateSelectedMap
(
this
.
getRawData
());
this
.
updateSelectedMap
(
this
.
_createSelectableList
());
},
getInitialData
:
function
(
option
)
{
...
...
@@ -40,11 +41,28 @@ var MapSeries = SeriesModel.extend({
},
mergeOption
:
function
(
newOption
)
{
this
.
_fillOption
(
newOption
,
this
.
getMapType
());
//
this._fillOption(newOption, this.getMapType());
MapSeries
.
superApply
(
this
,
'
mergeOption
'
,
arguments
);
this
.
updateSelectedMap
(
this
.
getRawData
());
this
.
updateSelectedMap
(
this
.
_createSelectableList
());
},
_createSelectableList
:
function
()
{
var
data
=
this
.
getRawData
();
var
valueDim
=
data
.
mapDimension
(
'
value
'
);
var
targetList
=
[];
for
(
var
i
=
0
,
len
=
data
.
count
();
i
<
len
;
i
++
)
{
targetList
.
push
({
name
:
data
.
getName
(
i
),
value
:
data
.
get
(
valueDim
,
i
),
selected
:
retrieveRawAttr
(
data
,
i
,
'
selected
'
)
});
}
targetList
=
geoCreator
.
getFilledRegions
(
targetList
,
this
.
getMapType
(),
this
.
option
.
nameMap
);
return
targetList
;
},
/**
...
...
src/chart/pie/PieSeries.js
浏览文件 @
242f6d02
...
...
@@ -4,6 +4,8 @@ import * as zrUtil from 'zrender/src/core/util';
import
*
as
modelUtil
from
'
../../util/model
'
;
import
{
getPercentWithPrecision
}
from
'
../../util/number
'
;
import
dataSelectableMixin
from
'
../../component/helper/selectableMixin
'
;
import
{
retrieveRawAttr
}
from
'
../../data/helper/dataProvider
'
;
var
PieSeries
=
echarts
.
extendSeriesModel
({
...
...
@@ -19,7 +21,7 @@ var PieSeries = echarts.extendSeriesModel({
return
this
.
getRawData
();
};
this
.
updateSelectedMap
(
this
.
getRawData
());
this
.
updateSelectedMap
(
this
.
_createSelectableList
());
this
.
_defaultLabelLine
(
option
);
},
...
...
@@ -28,13 +30,27 @@ var PieSeries = echarts.extendSeriesModel({
mergeOption
:
function
(
newOption
)
{
PieSeries
.
superCall
(
this
,
'
mergeOption
'
,
newOption
);
this
.
updateSelectedMap
(
this
.
getRawData
());
this
.
updateSelectedMap
(
this
.
_createSelectableList
());
},
getInitialData
:
function
(
option
,
ecModel
)
{
return
createListSimply
(
this
,
[
'
value
'
]);
},
_createSelectableList
:
function
()
{
var
data
=
this
.
getRawData
();
var
valueDim
=
data
.
mapDimension
(
'
value
'
);
var
targetList
=
[];
for
(
var
i
=
0
,
len
=
data
.
count
();
i
<
len
;
i
++
)
{
targetList
.
push
({
name
:
data
.
getName
(
i
),
value
:
data
.
get
(
valueDim
,
i
),
selected
:
retrieveRawAttr
(
data
,
i
,
'
selected
'
)
});
}
return
targetList
;
},
// Overwrite
getDataParams
:
function
(
dataIndex
)
{
var
data
=
this
.
getData
();
...
...
src/component/helper/selectableMixin.js
浏览文件 @
242f6d02
...
...
@@ -5,31 +5,17 @@
*/
import
*
as
zrUtil
from
'
zrender/src/core/util
'
;
import
{
retrieveRawAttr
}
from
'
../../data/helper/dataProvider
'
;
export
default
{
/**
* @param {Array.<Object>
|module:echars/data/List} targetList
* @param {Array.<Object>
} targetList [{name, value, selected}, ...]
* If targetList is an array, it should like [{name: ..., value: ...}, ...].
* If targetList is a "List", it must have coordDim: 'value' dimension and name.
*/
updateSelectedMap
:
function
(
targetList
)
{
if
(
zrUtil
.
isArray
(
targetList
))
{
this
.
_targetList
=
targetList
.
slice
();
}
else
{
var
ecList
=
targetList
;
var
valueDim
=
ecList
.
mapDimension
(
'
value
'
);
var
targetList
=
this
.
_targetList
=
[];
for
(
var
i
=
0
,
len
=
ecList
.
count
();
i
<
len
;
i
++
)
{
targetList
.
push
({
name
:
ecList
.
getName
(
i
),
value
:
ecList
.
get
(
valueDim
,
i
),
selected
:
retrieveRawAttr
(
ecList
,
i
,
'
selected
'
)
});
}
}
this
.
_targetList
=
zrUtil
.
isArray
(
targetList
)
?
targetList
.
slice
()
:
[];
this
.
_selectTargetMap
=
zrUtil
.
reduce
(
targetList
||
[],
function
(
targetMap
,
target
)
{
targetMap
.
set
(
target
.
name
,
target
);
return
targetMap
;
...
...
test/map.html
浏览文件 @
242f6d02
...
...
@@ -20,12 +20,6 @@
require
([
'
echarts
'
// 'echarts/chart/map',
// 'echarts/component/title',
// 'echarts/component/legend',
// 'echarts/component/visualMap',
// 'echarts/component/markPoint',
// 'echarts/component/tooltip'
],
function
(
echarts
)
{
require
([
'
map/js/china
'
],
function
()
{
...
...
@@ -47,7 +41,7 @@
chart
.
setOption
({
tooltip
:
{},
title
:
{
text
:
'
iphone销量
'
,
text
:
'
内蒙古和青海没数据也要能被选中
'
,
subtext
:
'
纯属虚构
'
,
left
:
'
center
'
},
...
...
@@ -127,13 +121,13 @@
{
name
:
'
广西
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
{
name
:
'
甘肃
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
{
name
:
'
山西
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
{
name
:
'
内蒙古
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
//
{name: '内蒙古',value: Math.round(Math.random()*1000)},
{
name
:
'
陕西
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
{
name
:
'
吉林
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
{
name
:
'
福建
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
{
name
:
'
贵州
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
{
name
:
'
广东
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
{
name
:
'
青海
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
//
{name: '青海',value: Math.round(Math.random()*1000)},
{
name
:
'
西藏
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
{
name
:
'
四川
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
{
name
:
'
宁夏
'
,
value
:
Math
.
round
(
Math
.
random
()
*
1000
)},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录