Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
6d898221
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,体验更适合开发者的 AI 搜索 >>
提交
6d898221
编写于
6月 13, 2018
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[custom series] (1) add params.actionType (2) add params.coordSys.zoom for geo (3) enhance merge.
上级
5cce1e77
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
21 deletion
+46
-21
src/chart/custom.js
src/chart/custom.js
+43
-20
src/coord/geo/prepareCustom.js
src/coord/geo/prepareCustom.js
+2
-1
src/view/Chart.js
src/view/Chart.js
+1
-0
未找到文件。
src/chart/custom.js
浏览文件 @
6d898221
...
...
@@ -74,7 +74,9 @@ echarts.extendSeriesModel({
coordinateSystem
:
'
cartesian2d
'
,
// Can be set as 'none'
zlevel
:
0
,
z
:
2
,
legendHoverLink
:
true
legendHoverLink
:
true
,
useTransform
:
true
// Cartesian coordinate system
// xAxisIndex: 0,
...
...
@@ -112,24 +114,27 @@ echarts.extendChartView({
/**
* @override
*/
render
:
function
(
customSeries
,
ecModel
,
api
)
{
render
:
function
(
customSeries
,
ecModel
,
api
,
payload
)
{
var
oldData
=
this
.
_data
;
var
data
=
customSeries
.
getData
();
var
group
=
this
.
group
;
var
renderItem
=
makeRenderItem
(
customSeries
,
data
,
ecModel
,
api
);
this
.
group
.
removeAll
();
// By default, merge mode is applied. In most cases, custom series is
// used in the scenario that data amount is not large but graphic elements
// is complicated, where merge mode is probably necessary for optimization.
// For example, reuse graphic elements and only update the transform when
// roam or data zoom according to `actionType`.
data
.
diff
(
oldData
)
.
add
(
function
(
newIdx
)
{
createOrUpdate
(
null
,
newIdx
,
renderItem
(
newIdx
),
customSeries
,
group
,
data
null
,
newIdx
,
renderItem
(
newIdx
,
payload
),
customSeries
,
group
,
data
);
})
.
update
(
function
(
newIdx
,
oldIdx
)
{
var
el
=
oldData
.
getItemGraphicEl
(
oldIdx
);
createOrUpdate
(
el
,
newIdx
,
renderItem
(
newIdx
),
customSeries
,
group
,
data
el
,
newIdx
,
renderItem
(
newIdx
,
payload
),
customSeries
,
group
,
data
);
})
.
remove
(
function
(
oldIdx
)
{
...
...
@@ -146,7 +151,7 @@ echarts.extendChartView({
this
.
_data
=
null
;
},
incrementalRender
:
function
(
params
,
customSeries
,
ecModel
,
api
)
{
incrementalRender
:
function
(
params
,
customSeries
,
ecModel
,
api
,
payload
)
{
var
data
=
customSeries
.
getData
();
var
renderItem
=
makeRenderItem
(
customSeries
,
data
,
ecModel
,
api
);
function
setIncrementalAndHoverLayer
(
el
)
{
...
...
@@ -156,7 +161,7 @@ echarts.extendChartView({
}
}
for
(
var
idx
=
params
.
start
;
idx
<
params
.
end
;
idx
++
)
{
var
el
=
createOrUpdate
(
null
,
idx
,
renderItem
(
idx
),
customSeries
,
this
.
group
,
data
);
var
el
=
createOrUpdate
(
null
,
idx
,
renderItem
(
idx
,
payload
),
customSeries
,
this
.
group
,
data
);
el
.
traverse
(
setIncrementalAndHoverLayer
);
}
},
...
...
@@ -328,13 +333,16 @@ function makeRenderItem(customSeries, data, ecModel, api) {
var
currLabelEmphasisModel
;
var
currVisualColor
;
return
function
(
dataIndexInside
)
{
return
function
(
dataIndexInside
,
payload
)
{
currDataIndexInside
=
dataIndexInside
;
currDirty
=
true
;
return
renderItem
&&
renderItem
(
zrUtil
.
defaults
({
dataIndexInside
:
dataIndexInside
,
dataIndex
:
data
.
getRawIndex
(
dataIndexInside
)
dataIndex
:
data
.
getRawIndex
(
dataIndexInside
),
// Can be used for optimization when zoom or roam.
actionType
:
payload
?
payload
.
type
:
null
},
userParams
),
userAPI
)
||
{};
...
...
@@ -495,13 +503,20 @@ function createOrUpdate(el, dataIndex, elOption, animatableModel, group, data) {
}
function
doCreateOrUpdate
(
el
,
dataIndex
,
elOption
,
animatableModel
,
group
,
data
)
{
elOption
=
elOption
||
{};
var
elOptionType
=
elOption
.
type
;
if
(
el
&&
elOptionType
!==
el
.
__customGraphicType
&&
(
elOptionType
!==
'
path
'
||
elOption
.
pathData
!==
el
.
__customPathData
)
&&
(
elOptionType
!==
'
image
'
||
elOption
.
style
.
image
!==
el
.
__customImagePath
)
&&
(
elOptionType
!==
'
text
'
||
elOption
.
style
.
text
!==
el
.
__customText
)
)
{
if
(
el
&&
(
// Also consider that if `renderItem` returns nothing, the original element
// (if exists) will be removed (elOption is an empty object in that case).
elOptionType
==
null
||
elOption
.
$merge
===
false
||
(
elOptionType
!==
el
.
__customGraphicType
&&
(
elOptionType
!==
'
path
'
||
elOption
.
pathData
!==
el
.
__customPathData
)
&&
(
elOptionType
!==
'
image
'
||
elOption
.
style
.
image
!==
el
.
__customImagePath
)
&&
(
elOptionType
!==
'
text
'
||
elOption
.
style
.
text
!==
el
.
__customText
)
)
))
{
group
.
remove
(
el
);
el
=
null
;
}
...
...
@@ -515,12 +530,18 @@ function doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data)
!
el
&&
(
el
=
createEl
(
elOption
));
updateEl
(
el
,
dataIndex
,
elOption
,
animatableModel
,
data
,
isInit
);
if
(
elOptionType
===
'
group
'
)
{
// If `renderItem` returns no children, follow the principle of
// "merge", remain the children of the original elements
// (if exists). The feature can help optimization when roam and
// data zoom. If intending to clear children, `renderItem` could
// returns an empty array as children.
var
newChildren
=
elOption
.
children
;
if
(
elOptionType
===
'
group
'
&&
newChildren
)
{
var
oldChildren
=
el
.
children
()
||
[];
var
newChildren
=
elOption
.
children
||
[];
// By default, do not diff elements by name inside a
// group, because that might be lower performance.
if
(
elOption
.
diffChildrenByName
)
{
// lower performance.
diffGroupChildren
({
oldChildren
:
oldChildren
,
newChildren
:
newChildren
,
...
...
@@ -530,8 +551,9 @@ function doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data)
data
:
data
});
}
// Mapping children of a group simply by index, which
// might be better performance.
else
{
// better performance.
var
index
=
0
;
for
(;
index
<
newChildren
.
length
;
index
++
)
{
doCreateOrUpdate
(
...
...
@@ -549,6 +571,7 @@ function doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data)
}
}
// Always add whatever already added to ensure sequence.
group
.
add
(
el
);
return
el
;
...
...
src/coord/geo/prepareCustom.js
浏览文件 @
6d898221
...
...
@@ -41,7 +41,8 @@ export default function (coordSys) {
x
:
rect
.
x
,
y
:
rect
.
y
,
width
:
rect
.
width
,
height
:
rect
.
height
height
:
rect
.
height
,
zoom
:
coordSys
.
getZoom
()
},
api
:
{
coord
:
function
(
data
)
{
...
...
src/view/Chart.js
浏览文件 @
6d898221
...
...
@@ -118,6 +118,7 @@ Chart.prototype = {
/**
* Render in progressive mode.
* @param {Object} params See taskParams in `stream/task.js`
* @param {module:echarts/model/Series} seriesModel
* @param {module:echarts/model/Global} ecModel
* @param {module:echarts/ExtensionAPI} api
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录