Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
19346eb5
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,发现更多精彩内容 >>
提交
19346eb5
编写于
11月 25, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tooltip hover connect
上级
1306bc81
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
72 addition
and
13 deletion
+72
-13
src/component/tooltip.js
src/component/tooltip.js
+72
-13
未找到文件。
src/component/tooltip.js
浏览文件 @
19346eb5
...
...
@@ -130,18 +130,46 @@ define(function (require) {
// Reset
this
.
group
.
removeAll
();
/**
* @type {Object}
* @private
*/
this
.
_axisPointers
=
{};
/**
* @private
* @type {module:echarts/component/tooltip/TooltipModel}
*/
this
.
_tooltipModel
=
tooltipModel
;
/**
* @private
* @type {module:echarts/model/Global}
*/
this
.
_ecModel
=
ecModel
;
/**
* @private
* @type {module:echarts/ExtensionAPI}
*/
this
.
_api
=
api
;
this
.
_lastHoverData
=
null
;
/**
* @type {Object}
* @private
*/
this
.
_lastHover
=
{
// data
// dataIndex
// seriesIndex
};
this
.
_tooltipContent
.
update
();
/**
* @type {Object.<string, Array>}
*/
this
.
_seriesGroupByAxis
=
this
.
_prepareAxisTriggerData
(
tooltipModel
,
ecModel
);
...
...
@@ -228,8 +256,6 @@ define(function (require) {
else
{
// Reset ticket
this
.
_ticket
=
''
;
// Reset lastHoverData
this
.
_lastHoverData
=
null
;
// If either single data or series use item trigger
this
.
_hideAxisPointer
();
this
.
_showItemTooltipContent
(
hostModel
,
dataIndex
,
e
);
...
...
@@ -256,6 +282,7 @@ define(function (require) {
_showAxisTooltip
:
function
(
tooltipModel
,
ecModel
,
e
)
{
var
axisPointerModel
=
tooltipModel
.
getModel
(
'
axisPointer
'
);
var
axisPointerType
=
axisPointerModel
.
get
(
'
type
'
);
var
api
=
this
.
_api
;
if
(
axisPointerType
===
'
cross
'
)
{
var
el
=
e
.
target
;
...
...
@@ -268,9 +295,9 @@ define(function (require) {
this
.
_showAxisPointer
();
var
allNotShow
=
true
;
zrUtil
.
each
(
this
.
_seriesGroupByAxis
,
function
(
item
)
{
zrUtil
.
each
(
this
.
_seriesGroupByAxis
,
function
(
seriesCoordSysSameAxis
)
{
// Try show the axis pointer
var
allCoordSys
=
item
.
coordSys
;
var
allCoordSys
=
seriesCoordSysSameAxis
.
coordSys
;
var
coordSys
=
allCoordSys
[
0
];
// If mouse position is not in the grid or polar
...
...
@@ -294,21 +321,22 @@ define(function (require) {
}
var
contentNotChange
=
false
;
var
lastHover
=
this
.
_lastHover
;
if
(
axisPointerType
===
'
cross
'
)
{
// If hover data not changed
// Possible when two axes are all category
if
(
dataEqual
(
this
.
_lastHoverD
ata
,
value
))
{
if
(
dataEqual
(
lastHover
.
d
ata
,
value
))
{
contentNotChange
=
true
;
}
this
.
_lastHoverD
ata
=
value
;
lastHover
.
d
ata
=
value
;
}
else
{
var
valIndex
=
zrUtil
.
indexOf
(
dimensions
,
axisType
);
// If hover data not changed on the axis dimension
if
(
this
.
_lastHoverD
ata
===
value
[
valIndex
])
{
if
(
lastHover
.
d
ata
===
value
[
valIndex
])
{
contentNotChange
=
true
;
}
this
.
_lastHoverD
ata
=
value
[
valIndex
];
lastHover
.
d
ata
=
value
[
valIndex
];
}
if
(
coordSys
.
type
===
'
cartesian2d
'
&&
!
contentNotChange
)
{
...
...
@@ -324,7 +352,7 @@ define(function (require) {
if
(
axisPointerType
!==
'
cross
'
)
{
this
.
_showSeriesTooltipContent
(
coordSys
,
item
.
series
,
point
,
value
,
contentNotChange
coordSys
,
seriesCoordSysSameAxis
.
series
,
point
,
value
,
contentNotChange
);
}
},
this
);
...
...
@@ -615,9 +643,30 @@ define(function (require) {
var
data
=
seriesList
[
0
].
getData
();
var
baseAxis
=
coordSys
.
getBaseAxis
();
var
val
=
value
[
baseAxis
.
dim
===
'
x
'
?
0
:
1
];
var
dataIndex
=
data
.
indexOfNearest
(
baseAxis
.
dim
,
val
);
var
lastHover
=
this
.
_lastHover
;
if
(
lastHover
.
seriesIndex
!=
null
)
{
this
.
_api
.
dispatch
({
type
:
'
downplay
'
,
seriesIndex
:
lastHover
.
seriesIndex
,
dataIndex
:
lastHover
.
dataIndex
});
}
var
seriesIndices
=
zrUtil
.
map
(
seriesList
,
function
(
series
)
{
return
series
.
seriesIndex
;
});
// Dispatch highlight action
this
.
_api
.
dispatch
({
type
:
'
highlight
'
,
seriesIndex
:
seriesIndices
,
dataIndex
:
dataIndex
});
lastHover
.
seriesIndex
=
seriesIndices
;
lastHover
.
dataIndex
=
dataIndex
;
if
(
baseAxis
&&
rootTooltipModel
.
get
(
'
showContent
'
))
{
var
val
=
value
[
baseAxis
.
dim
===
'
x
'
?
0
:
1
];
var
dataIndex
=
data
.
indexOfNearest
(
baseAxis
.
dim
,
val
);
var
formatter
=
rootTooltipModel
.
get
(
'
formatter
'
);
var
positionFunc
=
rootTooltipModel
.
get
(
'
position
'
);
...
...
@@ -811,7 +860,17 @@ define(function (require) {
* @param {string} [coordSysName]
*/
_hideAxisPointer
:
function
(
coordSysName
)
{
this
.
_lastHoverData
=
null
;
var
lastHover
=
this
.
_lastHover
;
if
(
lastHover
.
seriesIndex
!=
null
&&
lastHover
.
dataIndex
!=
null
)
{
this
.
_api
.
dispatch
({
type
:
'
downplay
'
,
seriesIndex
:
lastHover
.
seriesIndex
,
dataIndex
:
lastHover
.
dataIndex
});
}
// Reset lastHover
this
.
_lastHover
=
{};
if
(
coordSysName
)
{
var
axisPointers
=
this
.
_axisPointers
[
coordSysName
];
axisPointers
&&
zrUtil
.
each
(
axisPointers
,
function
(
el
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录