[Bug] the tooltip of generated svg using renderToSVGString is not working.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
- Ambito
- data-visualization, frontend
Direzione di ricerca
Inizia confrontando il comportamento del playground con l'output di renderToSVGString, quindi segui l'SVG generato e la gestione degli eventi del tooltip. Verifica se l'output SVG aperto in un browser può supportare l'interazione prevista del tooltip e aggiungi un controllo di regressione per il caso segnalato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 67.7k
- Fork
- 19.9k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/echarts
-
[Bug] String formatter templates only replace the first occurrence of `{a}`/`{b}`/`{c}`Forse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaen pending
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
-
[Bug] Inverse axis collapses the grid with outerBoundsContain when a tick is near the axis edgeForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaen pending
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
en pending
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
en pending
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
[Bug] The zoom cursor in the toolbox area is incorrectForse già presa @waterWang l’ha presa 98 giorni fa. Apertabug en pending
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Tutte le issue di apache/echarts
Issue simili
-
Stop retrying permanent GitHub API failures in retry.shForse già presa @muspi-merol-review l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
promplate/code-review#113 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
サムネイルの Storage のバケット(`thumbnails`)に、大きさの上限(1 MiB)と許可する種類(JPEG、PNG、WebP)を設定するForse già presa @ykzts l’ha presa oggi. Apertatech: supabase
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
inabagumi/shinju-date#7147 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
elecnix/your-attention#129 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
umami-software/umami#4780 ·
I maintainer di solito rispondono entro 3 giorni