[Bug] the tooltip of generated svg using renderToSVGString is not working.
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- typescript
调研方向
首先将 playground 的行为与 renderToSVGString 的输出进行比较,然后跟踪生成的 SVG 和 tooltip 事件处理。确认在浏览器中打开的 SVG 输出是否能够支持预期的 tooltip 交互,并为报告的案例添加回归检查。
由索引模型根据 Issue 内容生成。
描述
Version
5.2.2
Link to Minimal Reproduction
n.a.
Steps to Reproduce
use the same option (configure render to svg) in playground and renderToSVGString.
option = {
tooltip: { trigger: 'item' },
xAxis: {
type: 'category',
data: ['Apple', 'Banana', 'Orange', 'Melon', 'Grape']
},
yAxis: { type: 'value' },
series: [
{
name: 'Sales',
type: 'bar',
data: [120, 200, 150, 80, 70],
itemStyle: { color: '#5470c6' },
emphasis: { itemStyle: { color: 'Orange' } },
label: { show: true, position: 'top' }
}
]
};
Current Behavior
the svg in playground is highlight and tooltip enabled. But open the generated svg in browser, only highlight, the tooltip is not working as expected.
I did some research, the highlight works because the gnerated svg of renderToSVGString contains some embeded css styles. And the tooltip maybe need some embeded js which is missing now.
Here is an example svg embeded some js for tooltip demo.
svg source:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 200" width="400" height="200" style="background: #fafafa; border: 1px solid #ddd;">
<style>
.hover-target { cursor: help; fill-opacity: 0.8; }
.hover-target:hover { fill-opacity: 1; }
#tip-text {
font-family: sans-serif;
font-size: 14px;
fill: #333;
pointer-events: none; /* Prevents the tooltip from flickering when the mouse hits it */
font-weight: bold;
}
</style>
<circle class="hover-target" cx="80" cy="100" r="40" fill="#ff5722" data-tip="Orange Circle" />
<rect class="hover-target" x="160" y="60" width="80" height="80" fill="#2196f3" data-tip="Blue Square" />
<polygon class="hover-target" points="340,60 300,140 380,140" fill="#4caf50" data-tip="Green Triangle" />
<text id="tip-text" x="0" y="0" visibility="hidden">Tip Content</text>
<script type="text/javascript">
<![CDATA[
const svg = document.querySelector('svg');
const tooltip = document.getElementById('tip-text');
const targets = document.querySelectorAll('.hover-target');
function showTip(e) {
const msg = e.target.getAttribute('data-tip');
tooltip.textContent = msg;
tooltip.setAttribute('visibility', 'visible');
moveTip(e);
}
function moveTip(e) {
// Get mouse position relative to the SVG coordinate system
let CTM = svg.getScreenCTM();
let mouseX = (e.clientX - CTM.e) / CTM.a;
let mouseY = (e.clientY - CTM.f) / CTM.d;
// Position text 15px to the right and 5px above the cursor
tooltip.setAttribute('x', mouseX + 15);
tooltip.setAttribute('y', mouseY - 5);
}
function hideTip() {
tooltip.setAttribute('visibility', 'hidden');
}
targets.forEach(el => {
el.addEventListener('mouseover', showTip);
el.addEventListener('mousemove', moveTip);
el.addEventListener('mouseout', hideTip);
});
]]>
</script>
</svg>
Expected Behavior
the tooltip of generated svg using renderToSVGString is working like the normal usage. Maybe need to embed some js to svg.
Environment
- OS: windows
- Browser: edge, chrome
- Framework:
Any additional comments?
No response
- 主要语言
- TypeScript
- 星标
- 67.7k
- 派生
- 19.9k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/echarts 的其他 Issue
-
[Bug] String formatter templates only replace the first occurrence of `{a}`/`{b}`/`{c}`可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭en pending
难度 2/5 1-3 小时 新手友好度 80/100
-
[Bug] Inverse axis collapses the grid with outerBoundsContain when a tick is near the axis edge可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭en pending
难度 2/5 1-3 小时 新手友好度 82/100
-
en pending
难度 2/5 1-3 小时 新手友好度 78/100
-
en pending
难度 2/5 1-3 小时 新手友好度 78/100
-
[Bug] The zoom cursor in the toolbox area is incorrect可能已有人在做 @waterWang 于 98 天前认领。 未关闭bug en pending
难度 2/5 1-3 小时 新手友好度 70/100
相似的 Issue
-
Stop retrying permanent GitHub API failures in retry.sh可能已有人在做 @muspi-merol-review 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
promplate/code-review#113 · 1 条评论 ·
维护者通常 1 天内回复
-
triage
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
サムネイルの Storage のバケット(`thumbnails`)に、大きさの上限(1 MiB)と許可する種類(JPEG、PNG、WebP)を設定する可能已有人在做 @ykzts 今天认领。 未关闭tech: supabase
难度 2/5 1-3 小时 新手友好度 78/100
inabagumi/shinju-date#7147 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
elecnix/your-attention#129 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
umami-software/umami#4780 ·
维护者通常 3 天内回复