Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
bbff1547
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,发现更多精彩内容 >>
提交
bbff1547
编写于
10月 15, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tooltip fix for the situation two cartesian exists in one grid
上级
71d165aa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
77 addition
and
35 deletion
+77
-35
src/component/tooltip.js
src/component/tooltip.js
+65
-26
src/coord/cartesian/Cartesian2D.js
src/coord/cartesian/Cartesian2D.js
+4
-3
src/coord/polar/Polar.js
src/coord/polar/Polar.js
+8
-6
未找到文件。
src/component/tooltip.js
浏览文件 @
bbff1547
...
...
@@ -68,22 +68,53 @@ define(function (require) {
this
.
_tooltipContent
.
hide
();
var
seriesGroupByCoordSys
=
{};
// Prepare data for axis trigger
var
seriesGroupByAxis
=
{};
ecModel
.
eachSeries
(
function
(
seriesModel
)
{
var
coordSys
=
seriesModel
.
coordinateSystem
;
if
(
coordSys
)
{
var
name
=
coordSys
.
name
;
seriesGroupByCoordSys
[
name
]
=
seriesGroupByCoordSys
[
name
]
||
{
coordSys
:
coordSys
,
series
:
[]
};
seriesGroupByCoordSys
[
name
].
series
.
push
(
seriesModel
);
if
(
!
coordSys
)
{
return
;
}
var
coordSysType
=
coordSys
.
type
;
var
baseAxis
;
var
key
;
// Only cartesian2d and polar support axis trigger
if
(
coordSysType
===
'
cartesian2d
'
)
{
baseAxis
=
coordSys
.
getBaseAxis
();
var
baseDim
=
baseAxis
.
dim
;
var
axisIndex
=
seriesModel
.
get
(
baseDim
+
'
AxisIndex
'
);
key
=
baseDim
+
axisIndex
;
}
else
if
(
coordSysType
===
'
polar
'
)
{
baseAxis
=
coordSys
.
getBaseAxis
();
key
=
baseAxis
.
dim
+
coordSys
.
name
;
}
if
(
!
key
)
{
return
;
}
seriesGroupByAxis
[
key
]
=
seriesGroupByAxis
[
key
]
||
{
coordSys
:
[],
series
:
[]
};
seriesGroupByAxis
[
key
].
coordSys
.
push
(
coordSys
);
seriesGroupByAxis
[
key
].
series
.
push
(
seriesModel
);
},
this
);
this
.
_
coordinateSystems
=
seriesGroupByCoordSy
s
;
this
.
_
seriesGroupByAxis
=
seriesGroupByAxi
s
;
},
/**
* mousemove handler
* @param {Object} e
* @private
*/
_mouseMove
:
function
(
e
)
{
var
el
=
e
.
target
;
var
tooltipModel
=
this
.
_tooltipModel
;
...
...
@@ -115,34 +146,37 @@ define(function (require) {
/**
* Show tooltip on axis
* @param {Object} e
* @private
*/
_showAxisTooltip
:
function
(
e
)
{
var
tooltipModel
=
this
.
_tooltipModel
;
var
axisPointerModel
=
tooltipModel
.
getModel
(
'
axisPointer
'
);
zrUtil
.
each
(
this
.
_
coordinateSystem
s
,
function
(
item
)
{
zrUtil
.
each
(
this
.
_
seriesGroupByAxi
s
,
function
(
item
)
{
// Try show the axis pointer
this
.
group
.
show
();
var
coordSys
=
item
.
coordSys
;
var
allCoordSys
=
item
.
coordSys
;
var
coordSys
=
allCoordSys
[
0
];
// If mouse position is not in the grid or polar
var
point
=
[
e
.
offsetX
,
e
.
offsetY
];
if
(
coordSys
&&
!
coordSys
.
containPoint
(
point
))
{
if
(
!
coordSys
.
containPoint
(
point
))
{
// Hide axis pointer
this
.
_hide
();
return
;
}
// Make sure point is discrete on cateogry axis
var
value
=
coordSys
.
pointToData
(
point
);
var
value
=
coordSys
.
pointToData
(
point
,
true
);
point
=
coordSys
.
dataToPoint
(
value
);
if
(
coordSys
.
type
===
'
cartesian2d
'
)
{
this
.
_showCartesianPointer
(
axisPointerModel
,
c
oordSys
,
point
);
this
.
_showCartesianPointer
(
axisPointerModel
,
allC
oordSys
,
point
);
}
else
if
(
coordSys
.
type
===
'
polar
'
)
{
this
.
_showPolarPointer
(
axisPointerModel
,
c
oordSys
,
point
);
this
.
_showPolarPointer
(
axisPointerModel
,
allC
oordSys
,
point
);
}
this
.
_showSeriesTooltip
(
coordSys
,
item
.
series
,
point
,
value
);
...
...
@@ -153,25 +187,28 @@ define(function (require) {
/**
* Show tooltip on axis of cartesian coordinate
* @param {module:echarts/model/Model} axisPointerModel
* @param {
module:echarts/coord/cartesian/Cartesian2D} cartesian
* @param {
Array.<module:echarts/coord/cartesian/Cartesian2D>} cartesians
* @param {Array.<number>} point
* @private
*/
_showCartesianPointer
:
function
(
axisPointerModel
,
cartesian
,
point
)
{
_showCartesianPointer
:
function
(
axisPointerModel
,
cartesian
s
,
point
)
{
var
self
=
this
;
var
cateogryAxis
=
cartesian
.
getAxesByScale
(
'
ordinal
'
)[
0
];
var
axisPointerType
=
axisPointerModel
.
get
(
'
type
'
);
var
cartesian
=
cartesians
[
0
];
if
(
axisPointerType
===
'
cross
'
)
{
moveGridLine
(
'
x
'
,
point
,
cartesian
.
getAxis
(
'
y
'
).
getExtent
());
moveGridLine
(
'
y
'
,
point
,
cartesian
.
getAxis
(
'
x
'
).
getExtent
());
}
else
{
// Use the first cartesian
var
baseAxis
=
cartesian
.
getBaseAxis
();
var
axisType
=
axisPointerModel
.
get
(
'
axis
'
);
if
(
axisType
===
'
auto
'
)
{
axisType
=
(
cateogryAxis
&&
cateogry
Axis
.
dim
)
||
'
x
'
;
axisType
=
(
baseAxis
&&
base
Axis
.
dim
)
||
'
x
'
;
}
var
otherAxis
=
cartesian
.
getAxis
(
axisType
===
'
x
'
?
'
y
'
:
'
x
'
);
...
...
@@ -226,14 +263,16 @@ define(function (require) {
/**
* Show tooltip on axis of polar coordinate
* @param {module:echarts/model/Model} axisPointerModel
* @param {
module:echarts/coord/polar/Polar} polar
* @param {
Array.<module:echarts/coord/polar/Polar>} polars
* @param {Array.<number>} point
*/
_showPolarPointer
:
function
(
axisPointerModel
,
polar
,
point
)
{
_showPolarPointer
:
function
(
axisPointerModel
,
polar
s
,
point
)
{
var
self
=
this
;
var
axisPointerType
=
axisPointerModel
.
get
(
'
type
'
);
var
polar
=
polars
[
0
];
var
angleAxis
=
polar
.
getAngleAxis
();
var
radiusAxis
=
polar
.
getRadiusAxis
();
...
...
@@ -362,10 +401,10 @@ define(function (require) {
var
tooltipContent
=
this
.
_tooltipContent
;
var
data
=
seriesList
[
0
].
getData
();
var
categoryAxis
=
coordSys
.
getAxesByScale
(
'
ordinal
'
)[
0
]
;
if
(
category
Axis
&&
rootTooltipModel
.
get
(
'
showContent
'
))
{
var
rank
=
value
[
category
Axis
.
dim
===
'
x
'
?
0
:
1
];
var
dataIndex
=
data
.
indexOf
(
category
Axis
.
dim
,
rank
);
var
baseAxis
=
coordSys
.
getBaseAxis
()
;
if
(
base
Axis
&&
rootTooltipModel
.
get
(
'
showContent
'
))
{
var
rank
=
value
[
base
Axis
.
dim
===
'
x
'
?
0
:
1
];
var
dataIndex
=
data
.
indexOf
(
base
Axis
.
dim
,
rank
);
var
html
=
data
.
getName
(
dataIndex
)
+
'
<br />
'
+
zrUtil
.
map
(
seriesList
,
function
(
series
)
{
...
...
src/coord/cartesian/Cartesian2D.js
浏览文件 @
bbff1547
...
...
@@ -84,12 +84,13 @@ define(function(require) {
/**
* @param {Array.<number>} point
* @param {boolean} [clamp=false]
* @return {Array.<number>}
*/
pointToData
:
function
(
point
)
{
pointToData
:
function
(
point
,
clamp
)
{
return
[
this
.
getAxis
(
'
x
'
).
coordToData
(
point
[
0
]),
this
.
getAxis
(
'
y
'
).
coordToData
(
point
[
1
])
this
.
getAxis
(
'
x
'
).
coordToData
(
point
[
0
]
,
clamp
),
this
.
getAxis
(
'
y
'
).
coordToData
(
point
[
1
]
,
clamp
)
];
},
...
...
src/coord/polar/Polar.js
浏览文件 @
bbff1547
...
...
@@ -154,25 +154,27 @@ define(function(require) {
* Convert a single data item to (x, y) point.
* Parameter data is an array which the first element is radius and the second is angle
* @param {Array.<number>} data
* @param {boolean} [clamp=false]
* @return {Array.<number>}
*/
dataToPoint
:
function
(
data
)
{
dataToPoint
:
function
(
data
,
clamp
)
{
return
this
.
coordToPoint
([
this
.
_radiusAxis
.
dataToRadius
(
data
[
0
]),
this
.
_angleAxis
.
dataToAngle
(
data
[
1
])
this
.
_radiusAxis
.
dataToRadius
(
data
[
0
]
,
clamp
),
this
.
_angleAxis
.
dataToAngle
(
data
[
1
]
,
clamp
)
])
},
/**
* Convert a (x, y) point to data
* @param {Array.<number>} point
* @param {boolean} [clamp=false]
* @return {Array.<number>}
*/
pointToData
:
function
(
point
)
{
pointToData
:
function
(
point
,
clamp
)
{
var
coord
=
this
.
pointToCoord
(
point
);
return
[
this
.
_radiusAxis
.
radiusToData
(
coord
[
0
]),
this
.
_angleAxis
.
angleToData
(
coord
[
1
])
this
.
_radiusAxis
.
radiusToData
(
coord
[
0
]
,
clamp
),
this
.
_angleAxis
.
angleToData
(
coord
[
1
]
,
clamp
)
];
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录