Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
x649585723
incubator-echarts
提交
ff93e3e7
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,发现更多精彩内容 >>
提交
ff93e3e7
编写于
10月 15, 2015
作者:
L
lang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tooltip optimize
上级
47910327
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
140 addition
and
30 deletion
+140
-30
src/component/axis/AngleAxisView.js
src/component/axis/AngleAxisView.js
+2
-1
src/component/dataZoom/DataZoomView.js
src/component/dataZoom/DataZoomView.js
+1
-4
src/component/tooltip.js
src/component/tooltip.js
+75
-11
src/component/tooltip/TooltipModel.js
src/component/tooltip/TooltipModel.js
+5
-1
src/coord/Axis.js
src/coord/Axis.js
+19
-1
src/model/Series.js
src/model/Series.js
+9
-5
src/scale/Interval.js
src/scale/Interval.js
+11
-2
src/scale/Ordinal.js
src/scale/Ordinal.js
+2
-0
test/polarLine2.html
test/polarLine2.html
+8
-1
test/scatter.html
test/scatter.html
+8
-4
未找到文件。
src/component/axis/AngleAxisView.js
浏览文件 @
ff93e3e7
...
@@ -55,7 +55,8 @@ define(function (require) {
...
@@ -55,7 +55,8 @@ define(function (require) {
r
:
radiusExtent
[
1
]
r
:
radiusExtent
[
1
]
},
},
style
:
lineStyleModel
.
getLineStyle
(),
style
:
lineStyleModel
.
getLineStyle
(),
z2
:
1
z2
:
1
,
silent
:
true
});
});
circle
.
style
.
fill
=
null
;
circle
.
style
.
fill
=
null
;
...
...
src/component/dataZoom/DataZoomView.js
浏览文件 @
ff93e3e7
...
@@ -550,10 +550,7 @@ define(function (require) {
...
@@ -550,10 +550,7 @@ define(function (require) {
var
labelPrecision
=
dataZoomModel
.
get
(
'
labelPrecision
'
);
var
labelPrecision
=
dataZoomModel
.
get
(
'
labelPrecision
'
);
if
(
labelPrecision
==
null
)
{
if
(
labelPrecision
==
null
)
{
var
dataExtent
=
axis
.
scale
.
getExtent
();
labelPrecision
=
axis
.
getFormatPrecision
();
labelPrecision
=
Math
.
abs
(
Math
.
floor
(
Math
.
log
(
dataExtent
[
1
]
-
dataExtent
[
0
])
/
Math
.
LN10
)
);
}
}
return
(
value
==
null
&&
isNaN
(
value
))
return
(
value
==
null
&&
isNaN
(
value
))
...
...
src/component/tooltip.js
浏览文件 @
ff93e3e7
...
@@ -4,6 +4,9 @@ define(function (require) {
...
@@ -4,6 +4,9 @@ define(function (require) {
var
TooltipContent
=
require
(
'
./tooltip/TooltipContent
'
);
var
TooltipContent
=
require
(
'
./tooltip/TooltipContent
'
);
var
graphic
=
require
(
'
../util/graphic
'
);
var
graphic
=
require
(
'
../util/graphic
'
);
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
formatUtil
=
require
(
'
../util/format
'
);
require
(
'
./tooltip/TooltipModel
'
);
function
getAxisPointerKey
(
coordName
,
axisType
)
{
function
getAxisPointerKey
(
coordName
,
axisType
)
{
return
coordName
+
axisType
;
return
coordName
+
axisType
;
...
@@ -39,8 +42,6 @@ define(function (require) {
...
@@ -39,8 +42,6 @@ define(function (require) {
};
};
}
}
require
(
'
./tooltip/TooltipModel
'
);
require
(
'
../echarts
'
).
extendComponentView
({
require
(
'
../echarts
'
).
extendComponentView
({
type
:
'
tooltip
'
,
type
:
'
tooltip
'
,
...
@@ -83,6 +84,7 @@ define(function (require) {
...
@@ -83,6 +84,7 @@ define(function (require) {
// Only cartesian2d and polar support axis trigger
// Only cartesian2d and polar support axis trigger
if
(
coordSysType
===
'
cartesian2d
'
)
{
if
(
coordSysType
===
'
cartesian2d
'
)
{
// FIXME `axisPointer.axis` is not baseAxis
baseAxis
=
coordSys
.
getBaseAxis
();
baseAxis
=
coordSys
.
getBaseAxis
();
var
baseDim
=
baseAxis
.
dim
;
var
baseDim
=
baseAxis
.
dim
;
var
axisIndex
=
seriesModel
.
get
(
baseDim
+
'
AxisIndex
'
);
var
axisIndex
=
seriesModel
.
get
(
baseDim
+
'
AxisIndex
'
);
...
@@ -108,6 +110,11 @@ define(function (require) {
...
@@ -108,6 +110,11 @@ define(function (require) {
},
this
);
},
this
);
this
.
_seriesGroupByAxis
=
seriesGroupByAxis
;
this
.
_seriesGroupByAxis
=
seriesGroupByAxis
;
var
crossText
=
this
.
_crossText
;
if
(
crossText
)
{
this
.
group
.
add
(
crossText
);
}
},
},
/**
/**
...
@@ -132,15 +139,19 @@ define(function (require) {
...
@@ -132,15 +139,19 @@ define(function (require) {
return
;
return
;
}
}
var
seriesModel
=
ecModel
.
getSeriesByIndex
(
el
.
seriesIndex
);
this
.
_showItemTooltip
(
seriesModel
,
el
.
dataIndex
,
e
);
}
}
else
{
else
{
this
.
_showAxisTooltip
(
e
);
this
.
_showAxisTooltip
(
e
);
}
}
// Always show item tooltip if mouse is on the element with dataIndex
if
(
el
&&
el
.
dataIndex
)
{
var
seriesModel
=
ecModel
.
getSeriesByIndex
(
el
.
seriesIndex
);
this
.
_showItemTooltip
(
seriesModel
,
el
.
dataIndex
,
e
);
}
},
},
/**
/**
...
@@ -179,7 +190,9 @@ define(function (require) {
...
@@ -179,7 +190,9 @@ define(function (require) {
this
.
_showPolarPointer
(
axisPointerModel
,
allCoordSys
,
point
);
this
.
_showPolarPointer
(
axisPointerModel
,
allCoordSys
,
point
);
}
}
this
.
_showSeriesTooltip
(
coordSys
,
item
.
series
,
point
,
value
);
if
(
axisPointerModel
.
get
(
'
type
'
)
!==
'
cross
'
)
{
this
.
_showSeriesTooltip
(
coordSys
,
item
.
series
,
point
,
value
);
}
},
this
);
},
this
);
},
},
...
@@ -201,6 +214,8 @@ define(function (require) {
...
@@ -201,6 +214,8 @@ define(function (require) {
if
(
axisPointerType
===
'
cross
'
)
{
if
(
axisPointerType
===
'
cross
'
)
{
moveGridLine
(
'
x
'
,
point
,
cartesian
.
getAxis
(
'
y
'
).
getExtent
());
moveGridLine
(
'
x
'
,
point
,
cartesian
.
getAxis
(
'
y
'
).
getExtent
());
moveGridLine
(
'
y
'
,
point
,
cartesian
.
getAxis
(
'
x
'
).
getExtent
());
moveGridLine
(
'
y
'
,
point
,
cartesian
.
getAxis
(
'
x
'
).
getExtent
());
this
.
_updateCrossText
(
cartesian
,
point
,
axisPointerModel
);
}
}
else
{
else
{
// Use the first cartesian
// Use the first cartesian
...
@@ -277,8 +292,10 @@ define(function (require) {
...
@@ -277,8 +292,10 @@ define(function (require) {
var
radiusAxis
=
polar
.
getRadiusAxis
();
var
radiusAxis
=
polar
.
getRadiusAxis
();
if
(
axisPointerType
===
'
cross
'
)
{
if
(
axisPointerType
===
'
cross
'
)
{
movePolarLine
(
'
angle
'
,
point
,
angleAxis
.
getExtent
());
movePolarLine
(
'
angle
'
,
point
,
radiusAxis
.
getExtent
());
movePolarLine
(
'
radius
'
,
point
,
radiusAxis
.
getExtent
());
movePolarLine
(
'
radius
'
,
point
,
angleAxis
.
getExtent
());
this
.
_updateCrossText
(
polar
,
point
,
axisPointerModel
);
}
}
else
{
else
{
var
axisType
=
axisPointerModel
.
get
(
'
axis
'
);
var
axisType
=
axisPointerModel
.
get
(
'
axis
'
);
...
@@ -358,6 +375,50 @@ define(function (require) {
...
@@ -358,6 +375,50 @@ define(function (require) {
}
}
},
},
_updateCrossText
:
function
(
coordSys
,
point
,
axisPointerModel
)
{
var
crossStyleModel
=
axisPointerModel
.
getModel
(
'
crossStyle
'
);
var
textStyleModel
=
crossStyleModel
.
getModel
(
'
textStyle
'
);
var
tooltipModel
=
this
.
_tooltipModel
;
var
text
=
this
.
_crossText
;
if
(
!
text
)
{
text
=
this
.
_crossText
=
new
graphic
.
Text
({
style
:
{
textAlign
:
'
left
'
,
textBaseline
:
'
bottom
'
}
});
this
.
group
.
add
(
text
);
}
var
value
=
coordSys
.
pointToData
(
point
);
var
dims
=
coordSys
.
dimensions
;
value
=
zrUtil
.
map
(
value
,
function
(
val
,
idx
)
{
var
axis
=
coordSys
.
getAxis
(
dims
[
idx
]);
if
(
axis
.
type
===
'
category
'
)
{
val
=
axis
.
scale
.
getLabel
(
val
);
}
else
{
val
=
formatUtil
.
addCommas
(
val
.
toFixed
(
axis
.
getFormatPrecision
())
);
}
return
val
;
});
text
.
setStyle
({
fill
:
textStyleModel
.
get
(
'
color
'
)
||
crossStyleModel
.
get
(
'
color
'
),
textFont
:
textStyleModel
.
getFont
(),
text
:
value
.
join
(
'
,
'
),
x
:
point
[
0
]
+
5
,
y
:
point
[
1
]
-
5
});
text
.
z
=
tooltipModel
.
get
(
'
z
'
);
text
.
zlevel
=
tooltipModel
.
get
(
'
zlevel
'
);
},
/**
/**
* Hide axis tooltip
* Hide axis tooltip
*/
*/
...
@@ -366,7 +427,9 @@ define(function (require) {
...
@@ -366,7 +427,9 @@ define(function (require) {
},
},
_getPointerElement
:
function
(
coordSys
,
pointerModel
,
axisType
)
{
_getPointerElement
:
function
(
coordSys
,
pointerModel
,
axisType
)
{
var
z
=
this
.
_tooltipModel
.
get
(
'
z
'
);
var
tooltipModel
=
this
.
_tooltipModel
;
var
z
=
tooltipModel
.
get
(
'
z
'
);
var
zlevel
=
tooltipModel
.
get
(
'
zlevel
'
);
var
axisPointers
=
this
.
_axisPointers
;
var
axisPointers
=
this
.
_axisPointers
;
var
key
=
getAxisPointerKey
(
coordSys
.
name
,
axisType
);
var
key
=
getAxisPointerKey
(
coordSys
.
name
,
axisType
);
if
(
axisPointers
[
key
])
{
if
(
axisPointers
[
key
])
{
...
@@ -380,7 +443,7 @@ define(function (require) {
...
@@ -380,7 +443,7 @@ define(function (require) {
var
style
=
styleModel
[
isShadow
?
'
getAreaStyle
'
:
'
getLineStyle
'
]();
var
style
=
styleModel
[
isShadow
?
'
getAreaStyle
'
:
'
getLineStyle
'
]();
var
elementType
=
coordSys
.
type
===
'
polar
'
var
elementType
=
coordSys
.
type
===
'
polar
'
?
(
isShadow
?
'
Sector
'
:
'
Circle
'
)
?
(
isShadow
?
'
Sector
'
:
(
axisType
===
'
radius
'
?
'
Circle
'
:
'
Line
'
)
)
:
(
isShadow
?
'
Rect
'
:
'
Line
'
);
:
(
isShadow
?
'
Rect
'
:
'
Line
'
);
isShadow
?
(
style
.
stroke
=
null
)
:
(
style
.
fill
=
null
);
isShadow
?
(
style
.
stroke
=
null
)
:
(
style
.
fill
=
null
);
...
@@ -388,6 +451,7 @@ define(function (require) {
...
@@ -388,6 +451,7 @@ define(function (require) {
var
el
=
axisPointers
[
key
]
=
new
graphic
[
elementType
]({
var
el
=
axisPointers
[
key
]
=
new
graphic
[
elementType
]({
style
:
style
,
style
:
style
,
z
:
z
,
z
:
z
,
zlevel
:
zlevel
,
silent
:
true
silent
:
true
});
});
...
...
src/component/tooltip/TooltipModel.js
浏览文件 @
ff93e3e7
...
@@ -80,7 +80,11 @@ define(function (require) {
...
@@ -80,7 +80,11 @@ define(function (require) {
crossStyle
:
{
crossStyle
:
{
color
:
'
#1e90ff
'
,
color
:
'
#1e90ff
'
,
width
:
1
,
width
:
1
,
type
:
'
dashed
'
type
:
'
dashed
'
,
// TODO formatter
textStyle
:
{}
},
},
// 阴影指示器样式设置
// 阴影指示器样式设置
...
...
src/coord/Axis.js
浏览文件 @
ff93e3e7
define
(
function
(
require
)
{
define
(
function
(
require
)
{
var
linearMap
=
require
(
'
../util/number
'
).
linearMap
;
var
numberUtil
=
require
(
'
../util/number
'
)
var
linearMap
=
numberUtil
.
linearMap
;
var
zrUtil
=
require
(
'
zrender/core/util
'
);
var
zrUtil
=
require
(
'
zrender/core/util
'
);
function
fixExtentWithBands
(
extent
,
nTick
)
{
function
fixExtentWithBands
(
extent
,
nTick
)
{
...
@@ -82,6 +83,23 @@ define(function (require) {
...
@@ -82,6 +83,23 @@ define(function (require) {
return
ret
;
return
ret
;
},
},
/**
* Get precision used for formatting
* @return {number}
*/
getFormatPrecision
:
function
()
{
var
log
=
Math
.
log
;
var
LN10
=
Math
.
LN10
;
var
dataExtent
=
this
.
scale
.
getExtent
();
var
extent
=
this
.
_extent
;
var
dataQuantity
=
Math
.
floor
(
log
(
dataExtent
[
1
]
-
dataExtent
[
0
])
/
LN10
);
var
sizeQuantity
=
Math
.
ceil
(
log
(
Math
.
abs
(
extent
[
1
]
-
extent
[
0
]))
/
LN10
);
return
Math
.
max
(
-
dataQuantity
+
sizeQuantity
,
0
);
},
/**
/**
* Set coord extent
* Set coord extent
* @param {number} min
* @param {number} min
...
...
src/model/Series.js
浏览文件 @
ff93e3e7
...
@@ -118,11 +118,15 @@ define(function(require) {
...
@@ -118,11 +118,15 @@ define(function(require) {
var
data
=
this
.
_data
;
var
data
=
this
.
_data
;
var
value
=
data
.
getRawValue
(
dataIndex
);
var
value
=
data
.
getRawValue
(
dataIndex
);
var
formattedValue
=
zrUtil
.
isArray
(
value
)
var
formattedValue
=
zrUtil
.
isArray
(
value
)
?
zrUtil
.
map
(
value
,
addCommas
)
:
addCommas
(
value
);
?
zrUtil
.
map
(
value
,
addCommas
).
join
(
'
,
'
)
:
addCommas
(
value
);
var
name
=
data
.
getName
(
dataIndex
);
var
name
=
data
.
getName
(
dataIndex
,
true
);
return
!
mutipleSeries
?
(
encodeHTML
(
this
.
name
)
+
'
<br />
'
return
!
mutipleSeries
+
encodeHTML
(
name
)
+
'
:
'
+
formattedValue
)
?
(
encodeHTML
(
this
.
name
)
+
'
<br />
'
+
(
name
?
encodeHTML
(
name
)
+
'
:
'
+
formattedValue
:
formattedValue
)
)
:
(
encodeHTML
(
this
.
name
)
+
'
:
'
+
formattedValue
);
:
(
encodeHTML
(
this
.
name
)
+
'
:
'
+
formattedValue
);
},
},
...
...
src/scale/Interval.js
浏览文件 @
ff93e3e7
...
@@ -93,10 +93,10 @@ define(function (require) {
...
@@ -93,10 +93,10 @@ define(function (require) {
*/
*/
setExtent
:
function
(
start
,
end
)
{
setExtent
:
function
(
start
,
end
)
{
var
thisExtent
=
this
.
_extent
;
var
thisExtent
=
this
.
_extent
;
if
(
!
isNaN
(
start
))
{
if
(
!
isNaN
(
start
))
{
thisExtent
[
0
]
=
start
;
thisExtent
[
0
]
=
start
;
}
}
if
(
!
isNaN
(
end
))
{
if
(
!
isNaN
(
end
))
{
thisExtent
[
1
]
=
end
;
thisExtent
[
1
]
=
end
;
}
}
},
},
...
@@ -158,6 +158,15 @@ define(function (require) {
...
@@ -158,6 +158,15 @@ define(function (require) {
return
labels
;
return
labels
;
},
},
/**
* @param {number} n
* @return {number}
*/
// FIXME addCommas
getLabel
:
function
(
data
)
{
return
data
;
},
/**
/**
* Update interval and extent of intervals for nice ticks
* Update interval and extent of intervals for nice ticks
* Algorithm from d3.js
* Algorithm from d3.js
...
...
src/scale/Ordinal.js
浏览文件 @
ff93e3e7
...
@@ -142,6 +142,8 @@ define(function (require) {
...
@@ -142,6 +142,8 @@ define(function (require) {
/**
/**
* Get item on rank n
* Get item on rank n
* @param {number} n
* @return {string}
*/
*/
getLabel
:
function
(
n
)
{
getLabel
:
function
(
n
)
{
return
this
.
_data
[
n
];
return
this
.
_data
[
n
];
...
...
test/polarLine2.html
浏览文件 @
ff93e3e7
...
@@ -18,7 +18,8 @@
...
@@ -18,7 +18,8 @@
'
echarts
'
,
'
echarts
'
,
'
echarts/chart/line
'
,
'
echarts/chart/line
'
,
'
echarts/component/legend
'
,
'
echarts/component/legend
'
,
'
echarts/component/polar
'
'
echarts/component/polar
'
,
'
echarts/component/tooltip
'
],
function
(
echarts
)
{
],
function
(
echarts
)
{
var
chart
=
echarts
.
init
(
document
.
getElementById
(
'
main
'
),
null
,
{
var
chart
=
echarts
.
init
(
document
.
getElementById
(
'
main
'
),
null
,
{
...
@@ -38,6 +39,12 @@
...
@@ -38,6 +39,12 @@
data
:
[
'
line
'
]
data
:
[
'
line
'
]
},
},
polar
:
{},
polar
:
{},
tooltip
:
{
trigger
:
'
axis
'
,
axisPointer
:
{
type
:
'
cross
'
}
},
angleAxis
:
{
angleAxis
:
{
type
:
'
value
'
type
:
'
value
'
},
},
...
...
test/scatter.html
浏览文件 @
ff93e3e7
...
@@ -30,10 +30,14 @@
...
@@ -30,10 +30,14 @@
var
data2
=
[];
var
data2
=
[];
var
data3
=
[];
var
data3
=
[];
for
(
var
i
=
0
;
i
<
100
;
i
++
)
{
var
random
=
function
(
max
)
{
data1
.
push
([
Math
.
random
()
*
5
,
Math
.
random
()
*
4
,
Math
.
random
().
toFixed
(
2
)]);
return
(
Math
.
random
()
*
max
).
toFixed
(
3
);
data2
.
push
([
Math
.
random
()
*
10
,
Math
.
random
()
*
5
,
(
Math
.
random
()
+
0.3
).
toFixed
(
2
)]);
}
data3
.
push
([
Math
.
random
()
*
15
,
Math
.
random
()
*
10
,
Math
.
random
().
toFixed
(
2
)]);
for
(
var
i
=
0
;
i
<
200
;
i
++
)
{
data1
.
push
([
random
(
5
),
random
(
5
),
random
(
1
)]);
data2
.
push
([
random
(
10
),
random
(
10
),
random
(
1
)]);
data3
.
push
([
random
(
15
),
random
(
10
),
random
(
1
)]);
}
}
chart
.
setOption
({
chart
.
setOption
({
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录