Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
de20fcb5
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,发现更多精彩内容 >>
提交
de20fcb5
编写于
9月 17, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化 tooltip
上级
843a02c9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
107 addition
and
40 deletion
+107
-40
src/CoordinateSystem.js
src/CoordinateSystem.js
+3
-6
src/ExtensionAPI.js
src/ExtensionAPI.js
+1
-1
src/component/tooltip.js
src/component/tooltip.js
+61
-24
src/coord/polar/Polar.js
src/coord/polar/Polar.js
+13
-0
src/data/List.js
src/data/List.js
+22
-1
src/echarts.js
src/echarts.js
+0
-4
src/model/Series.js
src/model/Series.js
+7
-4
未找到文件。
src/CoordinateSystem.js
浏览文件 @
de20fcb5
...
...
@@ -8,6 +8,8 @@ define(function(require) {
function
CoordinateSystemManager
()
{
this
.
_coordinateSystems
=
{};
this
.
_coordinateSystemsList
=
[];
}
CoordinateSystemManager
.
prototype
=
{
...
...
@@ -19,6 +21,7 @@ define(function(require) {
for
(
var
type
in
coordinateSystemCreators
)
{
coordinateSystems
[
type
]
=
coordinateSystemCreators
[
type
].
create
(
ecModel
,
api
);
}
this
.
_coordinateSystems
=
coordinateSystems
;
},
...
...
@@ -27,12 +30,6 @@ define(function(require) {
if
(
list
)
{
return
list
[
idx
||
0
];
}
},
resize
:
function
(
ecModel
,
api
)
{
zrUtil
.
each
(
this
.
_coordinateSystems
,
function
(
coordinateSystem
)
{
coordinateSystem
.
resize
(
ecModel
,
api
);
});
}
}
...
...
src/ExtensionAPI.js
浏览文件 @
de20fcb5
...
...
@@ -5,7 +5,7 @@ define(function(require) {
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
echartsAPIList
=
[
'
getDom
'
,
'
getZr
'
,
'
get
CoordinateSystem
'
,
'
get
Width
'
,
'
getHeight
'
,
'
dispatch
'
'
getDom
'
,
'
getZr
'
,
'
getWidth
'
,
'
getHeight
'
,
'
dispatch
'
];
function
ExtensionAPI
(
echarts
)
{
...
...
src/component/tooltip.js
浏览文件 @
de20fcb5
...
...
@@ -3,6 +3,7 @@ define(function (require) {
var
TooltipContent
=
require
(
'
./tooltip/TooltipContent
'
);
var
graphic
=
require
(
'
../util/graphic
'
);
var
zrUtil
=
require
(
'
zrender/core/util
'
);
function
getAxisPointerKey
(
coordName
,
axisType
)
{
return
coordName
+
axisType
;
...
...
@@ -47,7 +48,9 @@ define(function (require) {
_axisPointers
:
{},
init
:
function
(
ecModel
,
api
)
{
api
.
getZr
().
on
(
'
mousemove
'
,
this
.
_mouseMove
,
this
);
var
zr
=
api
.
getZr
();
zr
.
on
(
'
mousemove
'
,
this
.
_mouseMove
,
this
);
zr
.
on
(
'
mouseout
'
,
this
.
_hide
,
this
);
this
.
_tooltipContent
=
new
TooltipContent
(
api
.
getDom
());
},
...
...
@@ -64,6 +67,19 @@ define(function (require) {
this
.
_api
=
api
;
this
.
_tooltipContent
.
hide
();
var
seriesGroupByCoordinateSystem
=
{};
ecModel
.
eachSeries
(
function
(
seriesModel
)
{
var
coordSys
=
seriesModel
.
coordinateSystem
;
var
name
=
coordSys
.
name
;
seriesGroupByCoordinateSystem
[
name
]
=
seriesGroupByCoordinateSystem
[
name
]
||
{
coordSys
:
coordSys
,
series
:
[]
};
seriesGroupByCoordinateSystem
[
name
].
series
.
push
(
seriesModel
);
},
this
);
this
.
_coordinateSystems
=
seriesGroupByCoordinateSystem
;
},
_mouseMove
:
function
(
e
)
{
...
...
@@ -79,7 +95,7 @@ define(function (require) {
if
(
trigger
===
'
item
'
)
{
if
(
!
el
||
el
.
dataIndex
==
null
)
{
this
.
_
tooltipContent
.
hideLater
(
tooltipModel
.
get
(
'
hideDelay
'
)
);
this
.
_
hide
(
);
return
;
}
...
...
@@ -99,31 +115,37 @@ define(function (require) {
* @param {Object} e
*/
_showAxisTooltip
:
function
(
e
)
{
var
ecModel
=
this
.
_ecModel
;
var
tooltipModel
=
this
.
_tooltipModel
;
var
axisPointerModel
=
tooltipModel
.
getModel
(
'
axisPointer
'
);
ecModel
.
eachSeries
(
function
(
seriesModel
)
{
zrUtil
.
each
(
this
.
_coordinateSystems
,
function
(
item
)
{
// Try show the axis pointer
this
.
group
.
show
();
var
coordSys
=
seriesModel
.
coordinateSystem
;
var
coordSys
=
item
.
coordSys
;
// If mouse position is not in the grid or polar
var
point
=
[
e
.
offsetX
,
e
.
offsetY
];
if
(
coordSys
&&
!
coordSys
.
containPoint
(
point
))
{
if
(
coordSys
&&
!
coordSys
.
containPoint
(
point
))
{
// Hide axis pointer
this
.
_hide
AxisTooltip
();
this
.
_hide
();
return
;
}
// Make sure point is discrete on cateogry axis
var
value
=
coordSys
.
pointToData
(
point
);
point
=
coordSys
.
dataToPoint
(
value
);
if
(
coordSys
.
type
===
'
cartesian2d
'
)
{
this
.
_showCartesianPointer
(
axisPointerModel
,
coordSys
,
point
);
}
else
if
(
coordSys
.
type
===
'
polar
'
)
{
this
.
_showPolarPointer
(
axisPointerModel
,
coordSys
,
point
);
}
},
this
)
this
.
_showSeriesTooltip
(
coordSys
,
item
.
series
,
point
,
value
);
},
this
);
},
/**
...
...
@@ -140,13 +162,6 @@ define(function (require) {
var
axisPointerType
=
axisPointerModel
.
get
(
'
type
'
);
var
value
=
cartesian
.
pointToData
(
point
);
// Make sure point is discrete on cateogry axis
if
(
cateogryAxis
)
{
point
=
cartesian
.
dataToPoint
(
value
);
}
if
(
axisPointerType
===
'
cross
'
)
{
moveGridLine
(
'
x
'
,
point
,
cartesian
.
getAxis
(
'
y
'
).
getExtent
());
moveGridLine
(
'
y
'
,
point
,
cartesian
.
getAxis
(
'
x
'
).
getExtent
());
...
...
@@ -204,7 +219,6 @@ define(function (require) {
shape
:
targetShape
});
}
},
/**
...
...
@@ -218,13 +232,9 @@ define(function (require) {
var
axisPointerType
=
axisPointerModel
.
get
(
'
type
'
);
var
value
=
polar
.
pointToData
(
point
);
var
angleAxis
=
polar
.
getAngleAxis
();
var
radiusAxis
=
polar
.
getRadiusAxis
();
// Make sure point is discrete on cateogry axis
point
=
polar
.
dataToPoint
(
value
);
if
(
axisPointerType
===
'
cross
'
)
{
movePolarLine
(
'
angle
'
,
point
,
angleAxis
.
getExtent
());
movePolarLine
(
'
radius
'
,
point
,
radiusAxis
.
getExtent
());
...
...
@@ -310,7 +320,7 @@ define(function (require) {
/**
* Hide axis tooltip
*/
_hideAxis
Tooltip
:
function
()
{
_hideAxis
Pointer
:
function
()
{
this
.
group
.
hide
();
},
...
...
@@ -342,8 +352,28 @@ define(function (require) {
return
el
;
},
_showSeriesTooltip
:
function
(
series
,
e
)
{
_showSeriesTooltip
:
function
(
coordSys
,
seriesList
,
point
,
value
)
{
var
rootTooltipModel
=
this
.
_tooltipModel
;
var
tooltipContent
=
this
.
_tooltipContent
;
var
data
=
seriesList
[
0
].
getData
();
var
categoryAxis
=
coordSys
.
getAxesByScale
(
'
ordinal
'
)[
0
];
if
(
categoryAxis
&&
rootTooltipModel
.
get
(
'
showContent
'
))
{
var
rank
=
value
[
categoryAxis
.
dim
===
'
x
'
?
0
:
1
];
var
dataIndex
=
data
.
indexOf
(
categoryAxis
.
dim
,
rank
);
var
html
=
data
.
getName
(
dataIndex
)
+
'
<br />
'
+
zrUtil
.
map
(
seriesList
,
function
(
series
)
{
return
series
.
formatTooltip
(
dataIndex
,
true
);
}).
join
(
'
<br />
'
);
tooltipContent
.
show
(
rootTooltipModel
);
tooltipContent
.
setContent
(
html
);
tooltipContent
.
moveTo
(
point
[
0
],
point
[
1
]);
}
},
/**
...
...
@@ -376,7 +406,7 @@ define(function (require) {
tooltipContent
.
show
(
tooltipModel
);
tooltipContent
.
setContent
(
seriesModel
.
formatTooltip
HTML
(
dataIndex
,
data
.
getName
(
dataIndex
)
)
seriesModel
.
formatTooltip
(
dataIndex
)
);
var
x
=
e
.
offsetX
+
20
;
...
...
@@ -385,8 +415,15 @@ define(function (require) {
}
},
_hide
:
function
()
{
this
.
_hideAxisPointer
();
this
.
_tooltipContent
.
hideLater
(
this
.
_tooltipModel
.
get
(
'
hideDelay
'
));
},
dispose
:
function
(
api
)
{
api
.
getZr
().
off
(
'
mousemove
'
,
this
.
_mouseMove
,
this
);
var
zr
=
api
.
getZr
();
zr
.
off
(
'
mousemove
'
,
this
.
_mouseMove
);
zr
.
off
(
'
mouseout
'
,
this
.
_hide
);
}
})
});
\ No newline at end of file
src/coord/polar/Polar.js
浏览文件 @
de20fcb5
...
...
@@ -67,6 +67,19 @@ define(function(require) {
return
this
[
'
_
'
+
axisType
+
'
Axis
'
];
},
/**
* Get axes by type of scale
*/
getAxesByScale
:
function
(
scaleType
)
{
var
axes
=
[];
var
angleAxis
=
this
.
_angleAxis
;
var
radiusAxis
=
this
.
_radiusAxis
;
angleAxis
.
scale
.
type
===
scaleType
&&
axes
.
push
(
angleAxis
);
radiusAxis
.
scale
.
type
===
scaleType
&&
axes
.
push
(
radiusAxis
);
return
axes
;
},
/**
* @return {module:echarts/coord/polar/AngleAxis}
*/
...
...
src/data/List.js
浏览文件 @
de20fcb5
...
...
@@ -15,7 +15,7 @@ define(function (require) {
float
:
Float32Array
,
int
:
Int32Array
,
'
number
'
:
Array
}
}
;
var
Model
=
require
(
'
../model/Model
'
);
var
DataDiffer
=
require
(
'
./DataDiffer
'
);
...
...
@@ -298,6 +298,27 @@ define(function (require) {
}
};
/**
* Retreive the index with given value
* @param {number} idx
* @param {number} value
* @return {number}
*/
// FIXME Precision of float value
listProto
.
indexOf
=
function
(
dim
,
value
)
{
var
storage
=
this
.
_storage
;
var
dimData
=
storage
[
dim
];
if
(
dimData
)
{
for
(
var
i
=
0
,
len
=
dimData
.
length
;
i
<
len
;
i
++
)
{
if
(
dimData
[
i
]
===
value
)
{
return
i
;
}
}
}
return
-
1
;
};
/**
* Get raw data index
* @param {number} idx
...
...
src/echarts.js
浏览文件 @
de20fcb5
...
...
@@ -144,10 +144,6 @@ define(function (require) {
},
getCoordinateSystem
:
function
(
type
,
idx
)
{
return
this
.
_coordinateSystem
.
get
(
type
,
idx
);
},
/**
* @return {number}
*/
...
...
src/model/Series.js
浏览文件 @
de20fcb5
...
...
@@ -87,20 +87,23 @@ define(function(require) {
return
this
.
_data
;
},
// FIXME
/**
* Default tooltip formatter
*
* @param {number} dataIndex
* @param {boolean} [mutipleSeries=false]
*/
formatTooltip
HTML
:
function
(
dataIndex
,
name
)
{
formatTooltip
:
function
(
dataIndex
,
mutipleSeries
)
{
var
data
=
this
.
_data
;
var
value
=
data
.
getRawValue
(
dataIndex
);
var
formattedValue
=
zrUtil
.
isArray
(
value
)
?
zrUtil
.
map
(
value
,
addCommas
)
:
addCommas
(
value
);
var
name
=
data
.
getName
(
dataIndex
);
return
encodeHTML
(
this
.
name
)
+
'
<br />
'
+
encodeHTML
(
name
)
+
'
:
'
+
formattedValue
;
return
!
mutipleSeries
?
(
encodeHTML
(
this
.
name
)
+
'
<br />
'
+
encodeHTML
(
name
)
+
'
:
'
+
formattedValue
)
:
(
encodeHTML
(
this
.
name
)
+
'
:
'
+
formattedValue
)
;
},
restoreData
:
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录