diff --git a/app/web/src/pages/Data.jsx b/app/web/src/pages/Data.jsx index e2e45e6..24b469a 100644 --- a/app/web/src/pages/Data.jsx +++ b/app/web/src/pages/Data.jsx @@ -184,7 +184,14 @@ function Courbes({ selection: { station, du, au }, d }) { if (r) setChoix(r.map(v => String(v).slice(0, 16).replace(" ", "T") + "Z")); }); barre.current.on("plotly_deselect", () => setChoix(null)); - barre.current.on("plotly_click", ev => courant.current.ouvrir(tries.current[ev.points[0].pointIndex])); + // Un clic sur une étiquette l'ouvre ; un clic ailleurs sur la barre (pas un glisser) la referme + let surEtiquette = false, x0 = 0; + barre.current.on("plotly_click", ev => { surEtiquette = true; courant.current.ouvrir(tries.current[ev.points[0].pointIndex]); }); + barre.current.addEventListener("mousedown", e => { x0 = e.clientX; }, true); + barre.current.addEventListener("click", e => { + if (!surEtiquette && Math.abs(e.clientX - x0) < 4) courant.current.ouvrir(null); + surEtiquette = false; + }); setPret(true); }); return () => [...Object.values(figs.current), barre.current].forEach(g => g && Plotly.purge(g));