Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
3ef4d9e7
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,发现更多精彩内容 >>
提交
3ef4d9e7
编写于
12月 15, 2015
作者:
P
pah100
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add throttle to datazoom inside
上级
ecb53a2d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
14 deletion
+67
-14
src/component/dataZoom/DataZoomView.js
src/component/dataZoom/DataZoomView.js
+27
-4
src/component/dataZoom/InsideZoomView.js
src/component/dataZoom/InsideZoomView.js
+23
-9
src/component/dataZoom/SliderZoomView.js
src/component/dataZoom/SliderZoomView.js
+3
-0
src/util/throttle.js
src/util/throttle.js
+14
-1
未找到文件。
src/component/dataZoom/DataZoomView.js
浏览文件 @
3ef4d9e7
...
...
@@ -18,10 +18,7 @@ define(function (require) {
*/
this
.
_lastThrottleRate
;
// FIXME
if
(
!
this
.
__doNotThrottle
)
{
this
.
_throttleDispatch
(
dataZoomModel
);
}
this
.
_throttleDispatch
(
dataZoomModel
);
},
/**
...
...
@@ -31,13 +28,25 @@ define(function (require) {
var
originDispatchZoomAction
=
this
.
constructor
.
prototype
.
dispatchZoomAction
;
if
(
originDispatchZoomAction
)
{
var
rate
=
dataZoomModel
.
get
(
'
throttle
'
);
if
(
this
.
_lastThrottleRate
!==
rate
)
{
this
.
_clearThrottle
();
this
.
dispatchZoomAction
=
throttle
.
fixedRate
(
originDispatchZoomAction
,
rate
);
this
.
_lastThrottleRate
=
rate
;
}
}
},
/**
* @private
*/
_clearThrottle
:
function
()
{
// Dispose
var
dispatchZoomAction
=
this
.
dispatchZoomAction
;
dispatchZoomAction
&&
dispatchZoomAction
.
clear
&&
dispatchZoomAction
.
clear
();
},
/**
* @protected
*/
...
...
@@ -45,6 +54,20 @@ define(function (require) {
// Implement by Children Classes.
},
/**
* @override
*/
remove
:
function
()
{
this
.
_clearThrottle
();
},
/**
* @override
*/
dispose
:
function
()
{
this
.
_clearThrottle
();
},
/**
* Find the first target coordinate system.
*
...
...
src/component/dataZoom/InsideZoomView.js
浏览文件 @
3ef4d9e7
...
...
@@ -11,18 +11,24 @@ define(function (require) {
type
:
'
dataZoom.inside
'
,
// FIXME
__doNotThrottle
:
true
,
/**
* @override
*/
init
:
function
(
ecModel
,
api
)
{
/**
* @private
* @type {Object.<string, module:echarts/component/helper/RoamController>}
*/
this
.
_controllers
=
{};
/**
* 'throttle' is used in this.dispatchAction, so we save range
* to avoid missing some 'pan' info.
* @private
* @type {Array.<number>}
*/
this
.
_range
;
},
/**
...
...
@@ -31,6 +37,13 @@ define(function (require) {
render
:
function
(
dataZoomModel
,
ecModel
,
api
,
payload
)
{
DataZoomView
.
prototype
.
render
.
apply
(
this
,
arguments
);
// Notice: this._resetInterval() should not be executed when payload.type
// is 'dataZoom', origin this._range should be maintained, otherwise 'pan'
// or 'zoom' info will be missed because of 'throttle' of this.dispatchAction,
if
(
!
payload
||
payload
.
type
!==
'
dataZoom
'
||
payload
.
from
!==
this
.
uid
)
{
this
.
_range
=
dataZoomModel
.
getRange
();
}
this
.
_resetController
(
api
);
},
...
...
@@ -38,6 +51,8 @@ define(function (require) {
* @override
*/
remove
:
function
()
{
DataZoomView
.
prototype
.
remove
.
apply
(
this
,
arguments
);
var
controllers
=
this
.
_controllers
;
zrUtil
.
each
(
controllers
,
function
(
controller
)
{
controller
.
off
(
'
pan
'
).
off
(
'
zoom
'
);
...
...
@@ -78,9 +93,8 @@ define(function (require) {
* @private
*/
_onPan
:
function
(
controller
,
coordInfo
,
dx
,
dy
)
{
var
dataZoomModel
=
this
.
dataZoomModel
;
var
range
=
panCartesian
(
[
dx
,
dy
],
dataZoomModel
.
getRange
(),
controller
,
coordInfo
var
range
=
this
.
_range
=
panCartesian
(
[
dx
,
dy
],
this
.
_range
,
controller
,
coordInfo
);
if
(
range
)
{
...
...
@@ -94,8 +108,8 @@ define(function (require) {
_onZoom
:
function
(
controller
,
coordInfo
,
scale
,
mouseX
,
mouseY
)
{
var
dataZoomModel
=
this
.
dataZoomModel
;
scale
=
1
/
scale
;
var
range
=
scaleCartesian
(
scale
,
[
mouseX
,
mouseY
],
dataZoomModel
.
getRange
()
,
var
range
=
this
.
_range
=
scaleCartesian
(
scale
,
[
mouseX
,
mouseY
],
this
.
_range
,
controller
,
coordInfo
,
dataZoomModel
);
...
...
@@ -111,7 +125,7 @@ define(function (require) {
type
:
'
dataZoom
'
,
from
:
this
.
uid
,
dataZoomId
:
this
.
dataZoomModel
.
id
,
range
:
range
range
:
range
.
slice
()
});
}
...
...
src/component/dataZoom/SliderZoomView.js
浏览文件 @
3ef4d9e7
...
...
@@ -102,6 +102,9 @@ define(function (require) {
return
;
}
// Notice: this._resetInterval() should not be executed when payload.type
// is 'dataZoom', origin this._range should be maintained, otherwise 'pan'
// or 'zoom' info will be missed because of 'throttle' of this.dispatchAction,
if
(
!
payload
||
payload
.
type
!==
'
dataZoom
'
||
payload
.
from
!==
this
.
uid
)
{
this
.
_buildView
();
}
...
...
src/util/throttle.js
浏览文件 @
3ef4d9e7
...
...
@@ -64,7 +64,7 @@ define(function () {
(
isSingle
?
fn
:
fn
[
index
]).
apply
(
scope
,
args
||
[]);
}
return
function
()
{
var
cb
=
function
()
{
currCall
=
(
new
Date
()).
getTime
();
scope
=
this
;
args
=
arguments
;
...
...
@@ -91,6 +91,19 @@ define(function () {
lastCall
=
currCall
;
};
/**
* Clear throttle.
* @public
*/
cb
.
clear
=
function
()
{
if
(
timer
)
{
clearTimeout
(
timer
);
timer
=
null
;
}
};
return
cb
;
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录