Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
4a7e92c5
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,发现更多精彩内容 >>
提交
4a7e92c5
编写于
8月 24, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Data diff
上级
0dc78665
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
112 addition
and
20 deletion
+112
-20
src/chart/bar/BarView.js
src/chart/bar/BarView.js
+31
-18
src/data/DataDiffer.js
src/data/DataDiffer.js
+72
-0
src/data/List.js
src/data/List.js
+5
-0
src/echarts.js
src/echarts.js
+2
-1
test/bar.html
test/bar.html
+2
-1
未找到文件。
src/chart/bar/BarView.js
浏览文件 @
4a7e92c5
...
...
@@ -17,24 +17,37 @@ define(function (require) {
},
_renderCartesian
:
function
(
seriesModel
,
ecModel
,
api
)
{
seriesModel
.
getData
().
each
(
function
(
dataItem
)
{
var
layout
=
dataItem
.
layout
;
var
rect
=
new
api
.
Rect
({
shape
:
{
x
:
layout
.
x
,
y
:
layout
.
y
,
width
:
layout
.
width
,
height
:
layout
.
height
},
style
:
{
fill
:
dataItem
.
getVisual
(
'
color
'
),
stroke
:
dataItem
.
get
(
'
itemStyle.normal.borderColor
'
)
}
});
this
.
group
.
add
(
rect
);
},
this
);
var
group
=
this
.
group
;
var
data
=
seriesModel
.
getData
();
data
.
diff
(
this
.
data
)
.
add
(
function
(
dataItem
)
{
var
rect
=
new
api
.
Rect
({
shape
:
dataItem
.
layout
,
style
:
{
fill
:
dataItem
.
getVisual
(
'
color
'
),
stroke
:
dataItem
.
get
(
'
itemStyle.normal.borderColor
'
)
}
});
dataItem
.
__el
=
rect
;
rect
.
__data
=
dataItem
;
group
.
add
(
rect
);
})
.
update
(
function
(
newData
,
oldData
)
{
// TODO DONT ANIMATE WHEN PROPERTIES ARE EQUAL
oldData
.
__el
.
animateShape
()
.
when
(
500
,
newData
.
layout
)
.
start
();
newData
.
__el
=
oldData
.
__el
;
})
.
remove
(
function
(
dataItem
)
{
group
.
remove
(
dataItem
.
__el
);
})
.
execute
();
this
.
data
=
data
;
}
});
...
...
src/data/DataDiffer.js
0 → 100644
浏览文件 @
4a7e92c5
define
(
function
(
require
)
{
'
use strict
'
;
function
DataDiffer
(
oldArr
,
newArr
)
{
this
.
_old
=
oldArr
;
this
.
_new
=
newArr
;
};
DataDiffer
.
prototype
=
{
constructor
:
DataDiffer
,
/**
* Callback function when add a data
*/
add
:
function
(
func
)
{
this
.
_add
=
func
;
return
this
;
},
/**
* Callback function when update a data
*/
update
:
function
(
func
)
{
this
.
_update
=
func
;
return
this
;
},
/**
* Callback function when remove a data
*/
remove
:
function
(
func
)
{
this
.
_remove
=
func
;
return
this
;
},
execute
:
function
()
{
var
oldArr
=
this
.
_old
;
var
newArr
=
this
.
_new
;
var
oldDataMap
=
{};
var
newDataMap
=
{};
var
i
;
for
(
i
=
0
;
i
<
oldArr
.
length
;
i
++
)
{
oldDataMap
[
oldArr
[
i
].
name
]
=
oldArr
[
i
];
}
for
(
i
=
0
;
i
<
newArr
.
length
;
i
++
)
{
newDataMap
[
newArr
[
i
].
name
]
=
newArr
[
i
];
}
for
(
i
=
0
;
i
<
oldArr
.
length
;
i
++
)
{
var
oldData
=
oldArr
[
i
];
var
newData
=
newDataMap
[
oldData
.
name
];
if
(
newData
)
{
this
.
_update
&&
this
.
_update
(
newData
,
oldData
);
}
else
{
this
.
_remove
&&
this
.
_remove
(
oldData
);
}
}
for
(
i
=
0
;
i
<
newArr
.
length
;
i
++
)
{
var
newData
=
newArr
[
i
];
if
(
!
oldDataMap
[
newData
.
name
])
{
this
.
_add
&&
this
.
_add
(
newData
);
}
}
}
};
return
DataDiffer
;
});
\ No newline at end of file
src/data/List.js
浏览文件 @
4a7e92c5
...
...
@@ -3,6 +3,7 @@ define(function(require) {
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
Model
=
require
(
'
../model/Model
'
);
var
DataDiffer
=
require
(
'
./DataDiffer
'
);
function
createArrayIterWithDepth
(
maxDepth
,
properties
,
cb
,
context
,
iterType
)
{
// Simple optimization to avoid read the undefined value in properties array
...
...
@@ -230,6 +231,10 @@ define(function(require) {
return
el
;
},
diff
:
function
(
oldList
)
{
return
new
DataDiffer
(
oldList
?
oldList
.
elements
:
[],
this
.
elements
);
},
clone
:
function
()
{
var
list
=
new
List
();
var
elements
=
this
.
elements
;
...
...
src/echarts.js
浏览文件 @
4a7e92c5
...
...
@@ -328,8 +328,9 @@ define(function (require) {
ecModel
.
eachSeries
(
function
(
seriesModel
,
idx
)
{
var
id
=
getSeriesId
(
seriesModel
.
option
,
idx
);
var
chart
=
this
.
_chartsMap
[
id
];
chart
.
render
(
seriesModel
,
ecModel
,
api
);
// PENDING 这里先添加 group,不然不能配置动画
this
.
_zr
.
add
(
chart
.
group
);
chart
.
render
(
seriesModel
,
ecModel
,
api
);
},
this
);
},
...
...
test/bar.html
浏览文件 @
4a7e92c5
...
...
@@ -33,6 +33,7 @@
console
.
profile
(
'
setOption
'
);
chart
.
setOption
({
legend
:
{
// TODO First bar unclickable
data
:
[{
name
:
'
bar
'
,
itemStyle
:
{
...
...
@@ -42,7 +43,7 @@
}
},
'
bar2
'
,
'
bar3
'
],
selected
:
{
'
bar
'
:
false
//
'bar': false
}
},
xAxis
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录