Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
半栈学徒
incubator-echarts
提交
438f4037
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,发现更多精彩内容 >>
提交
438f4037
编写于
3月 15, 2021
作者:
1
100pah
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: [tooltip] keep support tooltip on graphic component.
上级
35d9f60b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
146 addition
and
5 deletion
+146
-5
src/component/graphic/install.ts
src/component/graphic/install.ts
+26
-2
src/component/tooltip/TooltipView.ts
src/component/tooltip/TooltipView.ts
+4
-2
test/runTest/actions/__meta__.json
test/runTest/actions/__meta__.json
+1
-1
test/tooltip-component.html
test/tooltip-component.html
+115
-0
未找到文件。
src/component/graphic/install.ts
浏览文件 @
438f4037
...
...
@@ -30,7 +30,8 @@ import {
Dictionary
,
ZRStyleProps
,
OptionId
,
OptionPreprocessor
OptionPreprocessor
,
CommonTooltipOption
}
from
'
../../util/types
'
;
import
ComponentModel
from
'
../../model/Component
'
;
import
Element
,
{
ElementTextConfig
}
from
'
zrender/src/Element
'
;
...
...
@@ -44,6 +45,7 @@ import { getECData } from '../../util/innerStore';
import
{
TextStyleProps
}
from
'
zrender/src/graphic/Text
'
;
import
{
isEC4CompatibleStyle
,
convertFromEC4CompatibleStyle
}
from
'
../../util/styleCompat
'
;
import
{
EChartsExtensionInstallRegisters
}
from
'
../../extension
'
;
import
{
graphic
}
from
'
../../export/api
'
;
const
TRANSFORM_PROPS
=
{
x
:
1
,
...
...
@@ -129,6 +131,8 @@ interface GraphicComponentBaseElementOption extends
textConfig
?:
ElementTextConfig
;
$action
?:
'
merge
'
|
'
replace
'
|
'
remove
'
;
tooltip
?:
CommonTooltipOption
<
unknown
>
;
};
interface
GraphicComponentDisplayableOption
extends
GraphicComponentBaseElementOption
,
...
...
@@ -461,7 +465,8 @@ class GraphicComponentView extends ComponentView {
if
(
elOptionStyle
&&
isEC4CompatibleStyle
(
elOptionStyle
,
elType
,
!!
textConfig
,
!!
textContentOption
)
)
{
const
convertResult
=
convertFromEC4CompatibleStyle
(
elOptionStyle
,
elType
,
true
)
as
GraphicComponentZRPathOption
;
const
convertResult
=
convertFromEC4CompatibleStyle
(
elOptionStyle
,
elType
,
true
)
as
GraphicComponentZRPathOption
;
if
(
!
textConfig
&&
convertResult
.
textConfig
)
{
textConfig
=
(
elOption
as
GraphicComponentZRPathOption
).
textConfig
=
convertResult
.
textConfig
;
}
...
...
@@ -514,6 +519,25 @@ class GraphicComponentView extends ComponentView {
elInner
.
__ecGraphicWidthOption
=
(
elOption
as
GraphicComponentGroupOption
).
width
;
elInner
.
__ecGraphicHeightOption
=
(
elOption
as
GraphicComponentGroupOption
).
height
;
setEventData
(
el
,
graphicModel
,
elOption
);
const
tooltipOption
=
elOption
.
tooltip
;
const
componentIndex
=
graphicModel
.
componentIndex
;
getECData
(
el
).
tooltipConfig
=
tooltipOption
?
{
componentMainType
:
graphicModel
.
mainType
,
componentIndex
:
componentIndex
,
name
:
el
.
name
,
option
:
zrUtil
.
defaults
({
content
:
el
.
name
,
formatterParams
:
{
componentType
:
'
graphic
'
,
graphicIndex
:
componentIndex
,
name
:
el
.
name
,
$vars
:
[
'
name
'
]
}
},
tooltipOption
)
}
:
null
;
}
});
}
...
...
src/component/tooltip/TooltipView.ts
浏览文件 @
438f4037
...
...
@@ -723,9 +723,11 @@ class TooltipView extends ComponentView {
// that requires setting `trigger` nothing on component yet.
this
.
_showOrMove
(
subTooltipModel
,
function
(
this
:
TooltipView
)
{
// Use formatterParams from element defined in component
// Avoid users modify it.
const
formatterParams
=
zrUtil
.
clone
(
subTooltipModel
.
get
(
'
formatterParams
'
)
as
any
||
{});
this
.
_showTooltipContent
(
// Use formatterParams from element defined in component
subTooltipModel
,
defaultHtml
,
subTooltipModel
.
get
(
'
formatterParams
'
)
as
any
||
{},
subTooltipModel
,
defaultHtml
,
formatterParams
,
asyncTicket
,
e
.
offsetX
,
e
.
offsetY
,
e
.
position
,
el
,
markupStyleCreator
);
});
...
...
test/runTest/actions/__meta__.json
浏览文件 @
438f4037
...
...
@@ -151,7 +151,7 @@
"tooltip-axisPointer"
:
20
,
"tooltip-axisPointer2"
:
1
,
"tooltip-cascade"
:
4
,
"tooltip-component"
:
3
,
"tooltip-component"
:
4
,
"tooltip-event"
:
1
,
"tooltip-link"
:
2
,
"tooltip-rich"
:
1
,
...
...
test/tooltip-component.html
浏览文件 @
438f4037
...
...
@@ -39,6 +39,7 @@ under the License.
<div
id=
"main0"
></div>
<div
id=
"main1"
></div>
<div
id=
"axis-and-toolbox"
></div>
<div
id=
"graphic-component-tooltip"
></div>
...
...
@@ -251,6 +252,120 @@ under the License.
<script>
require
([
'
echarts
'
/*, 'map/js/china' */
],
function
(
echarts
)
{
var
option
;
option
=
{
tooltip
:
{
textStyle
:
{
fontSize
:
5
,
color
:
'
red
'
}
},
graphic
:
[{
tooltip
:
{
formatter
:
'
asdf
'
,
textStyle
:
{
fontSize
:
20
}
},
type
:
'
rect
'
,
name
:
'
1st
'
,
shape
:
{
y
:
20
,
x
:
250
,
width
:
40
,
height
:
40
},
textContent
:
{
style
:
{
text
:
'
show tooltip asdf
\n
in fontSize: 20 red
'
}
},
textConfig
:
{
position
:
'
bottom
'
},
style
:
{
fill
:
'
blue
'
}
},
{
type
:
'
rect
'
,
shape
:
{
y
:
20
,
x
:
350
,
width
:
40
,
height
:
40
},
textContent
:
{
style
:
{
text
:
'
show no tooltip
'
}
},
textConfig
:
{
position
:
'
bottom
'
},
style
:
{
fill
:
'
blue
'
}
},
{
type
:
'
rect
'
,
tooltip
:
{
formatter
:
function
(
param
)
{
return
'
<pre>
'
+
JSON
.
stringify
(
param
,
null
,
2
)
+
'
</pre>
'
;
},
textStyle
:
{
fontSize
:
20
}
},
name
:
'
3rd
'
,
shape
:
{
y
:
20
,
x
:
450
,
width
:
40
,
height
:
40
},
textContent
:
{
style
:
{
text
:
'
show tooltip JSON params
\n
in fontSize: 20 red
'
}
},
textConfig
:
{
position
:
'
bottom
'
},
style
:
{
fill
:
'
blue
'
}
}]
};
var
chart
=
testHelper
.
create
(
echarts
,
'
graphic-component-tooltip
'
,
{
title
:
[
'
Hover the graphic should show tooltip
'
,
'
check each tooltip
'
,
],
option
:
option
,
height
:
200
,
buttons
:
[{
text
:
'
trigger 1st graphic tooltip
'
,
onclick
:
function
()
{
chart
.
dispatchAction
({
type
:
'
showTip
'
,
graphicIndex
:
0
,
name
:
'
1st
'
});
}
},
{
text
:
'
trigger 3rd graphic tooltip
'
,
onclick
:
function
()
{
chart
.
dispatchAction
({
type
:
'
showTip
'
,
graphicIndex
:
0
,
name
:
'
3rd
'
});
}
}]
});
});
</script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录