Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
cfe39961
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,发现更多精彩内容 >>
提交
cfe39961
编写于
6月 04, 2017
作者:
P
pah100
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #5874 (postion not work when dispatch 'showTip' manually)
上级
95c42c49
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
196 addition
and
34 deletion
+196
-34
src/component/axisPointer.js
src/component/axisPointer.js
+1
-14
src/component/axisPointer/axisTrigger.js
src/component/axisPointer/axisTrigger.js
+29
-19
src/component/tooltip/TooltipView.js
src/component/tooltip/TooltipView.js
+2
-1
test/tooltip.html
test/tooltip.html
+164
-0
未找到文件。
src/component/axisPointer.js
浏览文件 @
cfe39961
...
@@ -43,19 +43,6 @@ define(function (require) {
...
@@ -43,19 +43,6 @@ define(function (require) {
type
:
'
updateAxisPointer
'
,
type
:
'
updateAxisPointer
'
,
event
:
'
updateAxisPointer
'
,
event
:
'
updateAxisPointer
'
,
update
:
'
:updateAxisPointer
'
update
:
'
:updateAxisPointer
'
},
function
(
payload
,
ecModel
,
api
)
{
},
axisTrigger
);
var
outputFinder
=
axisTrigger
(
ecModel
.
getComponent
(
'
axisPointer
'
).
coordSysAxesInfo
,
payload
.
currTrigger
,
[
payload
.
x
,
payload
.
y
],
payload
,
payload
.
dispatchAction
||
zrUtil
.
bind
(
api
.
dispatchAction
,
api
),
ecModel
,
api
,
payload
.
tooltipOption
);
return
outputFinder
;
});
});
});
\ No newline at end of file
src/component/axisPointer/axisTrigger.js
浏览文件 @
cfe39961
...
@@ -14,26 +14,35 @@ define(function(require) {
...
@@ -14,26 +14,35 @@ define(function(require) {
* then hide/downplay them.
* then hide/downplay them.
*
*
* @param {Object} coordSysAxesInfo
* @param {Object} coordSysAxesInfo
* @param {string} [currTrigger] 'click' | 'mousemove' | 'leave'
* @param {Object} payload
* @param {Array.<number>} [point] x and y, which are mandatory, specify a point to
* @param {string} [payload.currTrigger] 'click' | 'mousemove' | 'leave'
* @param {Array.<number>} [payload.x] x and y, which are mandatory, specify a point to
* tigger axisPointer and tooltip.
* tigger axisPointer and tooltip.
* @param {Object} [finder] {
* @param {Array.<number>} [payload.y] x and y, which are mandatory, specify a point to
* seriesIndex, dataIndex,
* tigger axisPointer and tooltip.
* axesInfo: [{
* @param {Object} [payload.seriesIndex] finder, optional, restrict target axes.
* axisDim: 'x'|'y'|'angle'|..., axisIndex: ..., value: ...
* @param {Object} [payload.dataIndex] finder, restrict target axes.
* }, ...]
* @param {Object} [payload.axesInfo] finder, restrict target axes.
* }
* [{
* These properties, which are optional, restrict target axes.
* axisDim: 'x'|'y'|'angle'|...,
* @param {Function} dispatchAction
* axisIndex: ...,
* value: ...
* }, ...]
* @param {Function} [payload.dispatchAction]
* @param {Object} [payload.tooltipOption]
* @param {Object|Array.<number>|Function} [payload.position] Tooltip position,
* which can be specified in dispatchAction
* @param {module:echarts/model/Global} ecModel
* @param {module:echarts/ExtensionAPI} api
* @param {module:echarts/ExtensionAPI} api
* @param {Object} [tooltipOption]
* @return {Object} content of event obj for echarts.connect.
* @return {Object} content of event obj for echarts.connect.
*/
*/
function
axisTrigger
(
function
axisTrigger
(
payload
,
ecModel
,
api
)
{
coordSysAxesInfo
,
currTrigger
,
point
,
finder
,
dispatchAction
,
var
currTrigger
=
payload
.
currTrigger
;
ecModel
,
api
,
tooltipOption
var
point
=
[
payload
.
x
,
payload
.
y
];
)
{
var
finder
=
payload
;
finder
=
finder
||
{};
var
dispatchAction
=
payload
.
dispatchAction
||
zrUtil
.
bind
(
api
.
dispatchAction
,
api
);
var
coordSysAxesInfo
=
ecModel
.
getComponent
(
'
axisPointer
'
).
coordSysAxesInfo
;
if
(
illegalPoint
(
point
))
{
if
(
illegalPoint
(
point
))
{
// Used in the default behavior of `connection`: use the sample seriesIndex
// Used in the default behavior of `connection`: use the sample seriesIndex
// and dataIndex. And also used in the tooltipView trigger.
// and dataIndex. And also used in the tooltipView trigger.
...
@@ -107,7 +116,7 @@ define(function(require) {
...
@@ -107,7 +116,7 @@ define(function(require) {
});
});
updateModelActually
(
showValueMap
,
axesInfo
,
outputFinder
);
updateModelActually
(
showValueMap
,
axesInfo
,
outputFinder
);
dispatchTooltipActually
(
dataByCoordSys
,
point
,
tooltipOption
,
dispatchAction
);
dispatchTooltipActually
(
dataByCoordSys
,
point
,
payload
,
dispatchAction
);
dispatchHighDownActually
(
axesInfo
,
dispatchAction
,
api
);
dispatchHighDownActually
(
axesInfo
,
dispatchAction
,
api
);
return
outputFinder
;
return
outputFinder
;
...
@@ -290,7 +299,7 @@ define(function(require) {
...
@@ -290,7 +299,7 @@ define(function(require) {
});
});
}
}
function
dispatchTooltipActually
(
dataByCoordSys
,
point
,
tooltipOption
,
dispatchAction
)
{
function
dispatchTooltipActually
(
dataByCoordSys
,
point
,
payload
,
dispatchAction
)
{
// Basic logic: If no showTip required, hideTip will be dispatched.
// Basic logic: If no showTip required, hideTip will be dispatched.
if
(
illegalPoint
(
point
)
||
!
dataByCoordSys
.
list
.
length
)
{
if
(
illegalPoint
(
point
)
||
!
dataByCoordSys
.
list
.
length
)
{
dispatchAction
({
type
:
'
hideTip
'
});
dispatchAction
({
type
:
'
hideTip
'
});
...
@@ -308,7 +317,8 @@ define(function(require) {
...
@@ -308,7 +317,8 @@ define(function(require) {
escapeConnect
:
true
,
escapeConnect
:
true
,
x
:
point
[
0
],
x
:
point
[
0
],
y
:
point
[
1
],
y
:
point
[
1
],
tooltipOption
:
tooltipOption
,
tooltipOption
:
payload
.
tooltipOption
,
position
:
payload
.
position
,
dataIndexInside
:
sampleItem
.
dataIndexInside
,
dataIndexInside
:
sampleItem
.
dataIndexInside
,
dataIndex
:
sampleItem
.
dataIndex
,
dataIndex
:
sampleItem
.
dataIndex
,
seriesIndex
:
sampleItem
.
seriesIndex
,
seriesIndex
:
sampleItem
.
seriesIndex
,
...
...
src/component/tooltip/TooltipView.js
浏览文件 @
cfe39961
...
@@ -265,7 +265,8 @@ define(function (require) {
...
@@ -265,7 +265,8 @@ define(function (require) {
api
.
dispatchAction
({
api
.
dispatchAction
({
type
:
'
updateAxisPointer
'
,
type
:
'
updateAxisPointer
'
,
seriesIndex
:
seriesIndex
,
seriesIndex
:
seriesIndex
,
dataIndex
:
dataIndex
dataIndex
:
dataIndex
,
position
:
payload
.
position
});
});
return
true
;
return
true
;
...
...
test/tooltip.html
浏览文件 @
cfe39961
...
@@ -40,6 +40,8 @@
...
@@ -40,6 +40,8 @@
<div
class=
"chart"
id=
"position"
></div>
<div
class=
"chart"
id=
"position"
></div>
<h1>
triggerOn click
</h1>
<h1>
triggerOn click
</h1>
<div
class=
"chart"
id=
"click"
></div>
<div
class=
"chart"
id=
"click"
></div>
<h1>
dispatchAciton manually with `position` specified (postion: [10,10])
</h1>
<div
class=
"chart"
id=
"positionSpecified"
></div>
<!--<h1>alwaysShowContent (check when hover on the last one, the content should not be the previous one)</h1>-->
<!--<h1>alwaysShowContent (check when hover on the last one, the content should not be the previous one)</h1>-->
<!--<div class="chart" id="alwaysShowContent"></div>-->
<!--<div class="chart" id="alwaysShowContent"></div>-->
...
@@ -646,6 +648,168 @@
...
@@ -646,6 +648,168 @@
<script>
require
([
'
echarts
'
,
'
echarts/chart/line
'
,
'
echarts/component/legend
'
,
'
echarts/component/grid
'
,
'
echarts/component/tooltip
'
,
'
zrender/vml/vml
'
],
function
(
echarts
)
{
var
option
=
{
title
:
{
text
:
'
未来一周气温变化
'
,
subtext
:
'
纯属虚构
'
},
tooltip
:
{
trigger
:
'
axis
'
},
legend
:
{
data
:[
'
最高气温
'
,
'
最低气温
'
]
},
toolbox
:
{
show
:
true
,
feature
:
{
dataZoom
:
{
yAxisIndex
:
'
none
'
},
dataView
:
{
readOnly
:
false
},
magicType
:
{
type
:
[
'
line
'
,
'
bar
'
]},
restore
:
{},
saveAsImage
:
{}
}
},
xAxis
:
{
type
:
'
category
'
,
boundaryGap
:
false
,
data
:
[
'
周一
'
,
'
周二
'
,
'
周三
'
,
'
周四
'
,
'
周五
'
,
'
周六
'
,
'
周日
'
]
},
yAxis
:
{
type
:
'
value
'
,
axisLabel
:
{
formatter
:
'
{value} °C
'
}
},
series
:
[
{
name
:
'
最高气温
'
,
type
:
'
line
'
,
data
:[
11
,
11
,
15
,
13
,
12
,
13
,
10
],
markPoint
:
{
data
:
[
{
type
:
'
max
'
,
name
:
'
最大值
'
},
{
type
:
'
min
'
,
name
:
'
最小值
'
}
]
},
markLine
:
{
data
:
[
{
type
:
'
average
'
,
name
:
'
平均值
'
}
]
}
},
{
name
:
'
最低气温
'
,
type
:
'
line
'
,
data
:[
1
,
-
2
,
2
,
5
,
3
,
2
,
0
],
markPoint
:
{
data
:
[
{
name
:
'
周最低
'
,
value
:
-
2
,
xAxis
:
1
,
yAxis
:
-
1.5
}
]
},
markLine
:
{
data
:
[
{
type
:
'
average
'
,
name
:
'
平均值
'
},
[{
symbol
:
'
none
'
,
x
:
'
90%
'
,
yAxis
:
'
max
'
},
{
symbol
:
'
circle
'
,
label
:
{
normal
:
{
position
:
'
start
'
,
formatter
:
'
最大值
'
}
},
type
:
'
max
'
,
name
:
'
最高点
'
}]
]
}
}
]
};
var
chart
=
createChart
(
'
positionSpecified
'
,
echarts
,
option
,
500
);
setTimeout
(
function
()
{
chart
.
dispatchAction
({
type
:
'
showTip
'
,
seriesIndex
:
0
,
dataIndex
:
0
,
position
:
function
()
{
return
[
10
,
10
];
}
})
},
1000
);
})
</script>
<script>
require
([
'
echarts
'
,
'
echarts/chart/line
'
,
'
echarts/component/legend
'
,
'
echarts/component/grid
'
,
'
echarts/component/tooltip
'
,
'
zrender/vml/vml
'
],
function
(
echarts
)
{
var
option
=
{
tooltip
:
{
trigger
:
'
axis
'
,
triggerOn
:
'
click
'
,
axisPointer
:
{
type
:
'
cross
'
}
}
};
var
baseTop
=
90
;
var
height
=
150
;
var
gap
=
50
;
makeCategoryGrid
(
option
,
{
grid
:
{
top
:
baseTop
,
height
:
height
},
yAxis
:
{
name
:
'
click show tip
'
,
tooltip
:
{
show
:
true
}
}
});
baseTop
+=
height
+
gap
;
createChart
(
'
click
'
,
echarts
,
option
,
baseTop
);
})
</script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录