Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
a86d780a
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,发现更多精彩内容 >>
提交
a86d780a
编写于
5月 29, 2018
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enable simulate browser scroll (dataZoom.moveOnMouseWheel)
上级
abc092fb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
208 addition
and
54 deletion
+208
-54
src/component/dataZoom/InsideZoomView.js
src/component/dataZoom/InsideZoomView.js
+52
-30
src/component/dataZoom/roams.js
src/component/dataZoom/roams.js
+6
-22
src/component/helper/RoamController.js
src/component/helper/RoamController.js
+3
-2
test/dataZoom-scroll.html
test/dataZoom-scroll.html
+147
-0
未找到文件。
src/component/dataZoom/InsideZoomView.js
浏览文件 @
a86d780a
...
...
@@ -63,6 +63,11 @@ var InsideZoomView = DataZoomView.extend({
var
coordModel
=
coordInfo
.
model
;
var
dataZoomOption
=
dataZoomModel
.
option
;
var
getRange
=
{};
zrUtil
.
each
([
'
pan
'
,
'
zoom
'
,
'
scrollMove
'
],
function
(
eventName
)
{
getRange
[
eventName
]
=
bind
(
roamHandlers
[
eventName
],
this
,
coordInfo
,
coordSysName
);
},
this
);
roams
.
register
(
api
,
{
...
...
@@ -73,8 +78,7 @@ var InsideZoomView = DataZoomView.extend({
},
dataZoomId
:
dataZoomModel
.
id
,
throttleRate
:
dataZoomModel
.
get
(
'
throttle
'
,
true
),
panGetRange
:
bind
(
this
.
_onPan
,
this
,
coordInfo
,
coordSysName
),
zoomGetRange
:
bind
(
this
.
_onZoom
,
this
,
coordInfo
,
coordSysName
),
getRange
:
getRange
,
zoomLock
:
dataZoomOption
.
zoomLock
,
disabled
:
dataZoomOption
.
disabled
,
roamControllerOpt
:
{
...
...
@@ -97,12 +101,16 @@ var InsideZoomView = DataZoomView.extend({
roams
.
unregister
(
this
.
api
,
this
.
dataZoomModel
.
id
);
InsideZoomView
.
superApply
(
this
,
'
dispose
'
,
arguments
);
this
.
_range
=
null
;
},
}
});
var
roamHandlers
=
{
/**
* @
private
* @
this {module:echarts/component/dataZoom/InsideZoomView}
*/
_onPan
:
function
(
coordInfo
,
coordSysName
,
controller
,
e
)
{
zoom
:
function
(
coordInfo
,
coordSysName
,
controller
,
e
)
{
var
lastRange
=
this
.
_range
;
var
range
=
lastRange
.
slice
();
...
...
@@ -113,14 +121,22 @@ var InsideZoomView = DataZoomView.extend({
}
var
directionInfo
=
getDirectionInfo
[
coordSysName
](
[
e
.
oldX
,
e
.
oldY
],
[
e
.
newX
,
e
.
new
Y
],
axisModel
,
controller
,
coordInfo
null
,
[
e
.
originX
,
e
.
origin
Y
],
axisModel
,
controller
,
coordInfo
);
var
percentPoint
=
(
directionInfo
.
signal
>
0
?
(
directionInfo
.
pixelStart
+
directionInfo
.
pixelLength
-
directionInfo
.
pixel
)
:
(
directionInfo
.
pixel
-
directionInfo
.
pixelStart
)
)
/
directionInfo
.
pixelLength
*
(
range
[
1
]
-
range
[
0
])
+
range
[
0
];
var
percentDelta
=
directionInfo
.
signal
*
(
range
[
1
]
-
range
[
0
])
*
directionInfo
.
pixel
/
directionInfo
.
pixelLength
;
var
scale
=
Math
.
max
(
1
/
e
.
scale
,
0
);
range
[
0
]
=
(
range
[
0
]
-
percentPoint
)
*
scale
+
percentPoint
;
range
[
1
]
=
(
range
[
1
]
-
percentPoint
)
*
scale
+
percentPoint
;
sliderMove
(
percentDelta
,
range
,
[
0
,
100
],
'
all
'
);
// Restrict range.
var
minMaxSpan
=
this
.
dataZoomModel
.
findRepresentativeAxisProxy
().
getMinMaxSpan
();
sliderMove
(
0
,
range
,
[
0
,
100
],
0
,
minMaxSpan
.
minSpan
,
minMaxSpan
.
maxSpan
);
this
.
_range
=
range
;
...
...
@@ -130,9 +146,28 @@ var InsideZoomView = DataZoomView.extend({
},
/**
* @
private
* @
this {module:echarts/component/dataZoom/InsideZoomView}
*/
_onZoom
:
function
(
coordInfo
,
coordSysName
,
controller
,
e
)
{
pan
:
makeMover
(
function
(
range
,
axisModel
,
coordInfo
,
coordSysName
,
controller
,
e
)
{
var
directionInfo
=
getDirectionInfo
[
coordSysName
](
[
e
.
oldX
,
e
.
oldY
],
[
e
.
newX
,
e
.
newY
],
axisModel
,
controller
,
coordInfo
);
return
directionInfo
.
signal
*
(
range
[
1
]
-
range
[
0
])
*
directionInfo
.
pixel
/
directionInfo
.
pixelLength
;
}),
/**
* @this {module:echarts/component/dataZoom/InsideZoomView}
*/
scrollMove
:
makeMover
(
function
(
range
,
axisModel
,
coordInfo
,
coordSysName
,
controller
,
e
)
{
return
(
range
[
1
]
-
range
[
0
])
*
e
.
scrollDelta
;
})
};
function
makeMover
(
getPercentDelta
)
{
return
function
(
coordInfo
,
coordSysName
,
controller
,
e
)
{
var
lastRange
=
this
.
_range
;
var
range
=
lastRange
.
slice
();
...
...
@@ -142,32 +177,19 @@ var InsideZoomView = DataZoomView.extend({
return
;
}
var
directionInfo
=
getDirectionInfo
[
coordSysName
]
(
null
,
[
e
.
originX
,
e
.
originY
],
axisModel
,
controller
,
coordInfo
var
percentDelta
=
getPercentDelta
(
range
,
axisModel
,
coordInfo
,
coordSysName
,
controller
,
e
);
var
percentPoint
=
(
directionInfo
.
signal
>
0
?
(
directionInfo
.
pixelStart
+
directionInfo
.
pixelLength
-
directionInfo
.
pixel
)
:
(
directionInfo
.
pixel
-
directionInfo
.
pixelStart
)
)
/
directionInfo
.
pixelLength
*
(
range
[
1
]
-
range
[
0
])
+
range
[
0
];
var
scale
=
Math
.
max
(
1
/
e
.
scale
,
0
);
range
[
0
]
=
(
range
[
0
]
-
percentPoint
)
*
scale
+
percentPoint
;
range
[
1
]
=
(
range
[
1
]
-
percentPoint
)
*
scale
+
percentPoint
;
// Restrict range.
var
minMaxSpan
=
this
.
dataZoomModel
.
findRepresentativeAxisProxy
().
getMinMaxSpan
();
sliderMove
(
0
,
range
,
[
0
,
100
],
0
,
minMaxSpan
.
minSpan
,
minMaxSpan
.
maxSpan
);
sliderMove
(
percentDelta
,
range
,
[
0
,
100
],
'
all
'
);
this
.
_range
=
range
;
if
(
lastRange
[
0
]
!==
range
[
0
]
||
lastRange
[
1
]
!==
range
[
1
])
{
return
range
;
}
}
});
};
}
var
getDirectionInfo
=
{
...
...
src/component/dataZoom/roams.js
浏览文件 @
a86d780a
...
...
@@ -41,8 +41,10 @@ var ATTR = '\0_ec_dataZoom_roams';
* @param {Array.<string>} dataZoomInfo.allCoordIds
* @param {string} dataZoomInfo.dataZoomId
* @param {number} dataZoomInfo.throttleRate
* @param {Function} dataZoomInfo.panGetRange
* @param {Function} dataZoomInfo.zoomGetRange
* @param {Object} dataZoomInfo.getRange
* @param {Function} dataZoomInfo.getRange.pan
* @param {Function} dataZoomInfo.getRange.zoom
* @param {Function} dataZoomInfo.getRange.scrollMove
* @param {boolean} [dataZoomInfo.zoomLock]
* @param {boolean} [dataZoomInfo.disabled]
*/
...
...
@@ -140,8 +142,8 @@ function createController(api, newRecord) {
zrUtil
.
each
([
'
pan
'
,
'
zoom
'
,
'
scrollMove
'
],
function
(
eventName
)
{
controller
.
on
(
eventName
,
function
(
event
)
{
wrapAndDispatch
(
newRecord
,
function
(
info
)
{
var
method
Name
=
eventName
+
'
GetRange
'
;
return
info
[
methodName
]
&&
info
[
methodName
]
(
newRecord
.
controller
,
event
);
var
method
=
(
info
.
getRange
||
{})[
eventName
]
;
return
method
&&
method
(
newRecord
.
controller
,
event
);
});
});
});
...
...
@@ -158,24 +160,6 @@ function cleanStore(store) {
});
}
// function onPan(record, dx, dy, oldX, oldY, newX, newY) {
// wrapAndDispatch(record, function (info) {
// return info.panGetRange(record.controller, dx, dy, oldX, oldY, newX, newY);
// });
// }
// function onZoom(record, scale, mouseX, mouseY) {
// wrapAndDispatch(record, function (info) {
// return info.zoomGetRange(record.controller, scale, mouseX, mouseY);
// });
// }
// function onScrollMove(record, scrollDelta) {
// wrapAndDispatch(record, function (info) {
// return info.scrollMoveGetRange(record.controller, scrollDelta);
// });
// }
function
wrapAndDispatch
(
record
,
getRange
)
{
var
batch
=
[];
...
...
src/component/helper/RoamController.js
浏览文件 @
a86d780a
...
...
@@ -210,8 +210,9 @@ function mousewheel(e) {
// FIXME: Should do more test in different environment.
var
absDelta
=
Math
.
abs
(
wheelDelta
);
// wheelDelta of mouse wheel is bigger than touch pad.
var
scrollDelta
=
absDelta
>
3
?
1.4
:
absDelta
>
1
?
1.2
:
1.1
;
this
.
trigger
(
'
scrollMove
'
,
{
scrollDelta
:
scrollDelta
});
var
scrollDelta
=
absDelta
>
3
?
0.4
:
absDelta
>
1
?
0.15
:
0.05
;
var
sign
=
wheelDelta
>
0
?
1
:
-
1
;
this
.
trigger
(
'
scrollMove
'
,
{
scrollDelta
:
sign
*
scrollDelta
});
}
}
...
...
test/dataZoom-scroll.html
0 → 100644
浏览文件 @
a86d780a
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<script
src=
"./lib/esl.js"
></script>
<script
src=
"./lib/config.js"
></script>
<script
src=
"./lib/facePrint.js"
></script>
<script
src=
"lib/testHelper.js"
></script>
<link
rel=
"stylesheet"
href=
"lib/reset.css"
/>
</head>
<body>
<style>
h1
{
line-height
:
60px
;
height
:
60px
;
background
:
#ddd
;
text-align
:
center
;
font-weight
:
bold
;
font-size
:
14px
;
}
.chart
{
height
:
500px
;
}
</style>
<div
class=
"chart"
id=
"d3"
></div>
<script>
require
([
'
data/rainfall.json
'
,
'
echarts
'
],
function
(
data
,
echarts
)
{
var
option
=
{
tooltip
:
{
trigger
:
'
axis
'
},
grid
:
[
{
show
:
true
,
borderWidth
:
0
}
],
xAxis
:
[
{
type
:
'
category
'
,
boundaryGap
:
true
,
axisLabel
:
{
show
:
true
},
splitLine
:
{
show
:
false
},
data
:
data
.
category
,
gridIndex
:
0
}
],
yAxis
:
[
{
boundaryGap
:
false
,
axisLabel
:
{
},
axisLine
:
{
lineStyle
:
{
color
:
'
#666
'
}
},
gridIndex
:
0
}
],
series
:
[
{
name
:
'
降水量
'
,
type
:
'
line
'
,
data
:
data
.
rainfall
,
itemStyle
:
{
normal
:
{
areaStyle
:
{}
}
},
xAxisIndex
:
0
,
yAxisIndex
:
0
,
}
],
dataZoom
:
[
{
type
:
'
inside
'
,
yAxisIndex
:
0
,
zoomOnMouseWheel
:
false
,
// moveOnMouseMove: 'alt',
moveOnMouseWheel
:
true
,
// zoomLock: true,
start
:
30
,
end
:
40
},
// {
// type: 'inside',
// // zoomOnMouseWheel: false,
// // moveOnMouseMove: 'alt',
// yAxisIndex: 0,
// zoomLock: true,
// start: 30,
// end: 40
// },
{
type
:
'
slider
'
,
start
:
30
,
end
:
40
},
{
type
:
'
slider
'
,
yAxisIndex
:
0
}
]
};
testHelper
.
create
(
echarts
,
'
d3
'
,
{
title
:
'
Simulate browser scroll bar
'
,
option
:
option
,
height
:
600
});
})
</script>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录