From e93e807325b1f91c89b6b42cb92804e078149e6e Mon Sep 17 00:00:00 2001 From: alberto Date: Thu, 3 Dec 2026 17:32:41 -0600 Subject: [PATCH] Box charts hover only Q3, Mediana and Q1, through an invisible marker; the box itself takes no hover --- src/app/indicadores/figures.ts | 11 ++++++++++- src/app/indicadores/tea-indicators.spec.ts | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/indicadores/figures.ts b/src/app/indicadores/figures.ts index 454d607..b1dcbe9 100644 --- a/src/app/indicadores/figures.ts +++ b/src/app/indicadores/figures.ts @@ -287,8 +287,17 @@ export function boxFigure(r: Reading, period: string): Figure { upperfence: [q3], marker: { color: '#4269C2' }, fillcolor: 'rgba(66,105,194,0.55)', - hovertemplate: `Q3: %{q3:${SHORT}}
Mediana: %{median:${SHORT}}
Q1: %{q1:${SHORT}}`, + hoverinfo: 'skip', } as Partial, + { + type: 'scatter', + mode: 'markers', + x: [period], + y: [r.score!], + customdata: [[q3, r.score!, q1]], + marker: { size: 40, opacity: 0 }, + hovertemplate: `Q3: %{customdata[0]:${SHORT}}
Mediana: %{customdata[1]:${SHORT}}
Q1: %{customdata[2]:${SHORT}}`, + }, ], layout: { showlegend: false, diff --git a/src/app/indicadores/tea-indicators.spec.ts b/src/app/indicadores/tea-indicators.spec.ts index 3a07991..a3623a0 100644 --- a/src/app/indicadores/tea-indicators.spec.ts +++ b/src/app/indicadores/tea-indicators.spec.ts @@ -409,7 +409,12 @@ describe('TEA clinical figures', () => { q1: [8], median: [12.5], q3: [20], - hovertemplate: 'Q3: %{q3:.1~f}
Mediana: %{median:.1~f}
Q1: %{q1:.1~f}', + hoverinfo: 'skip', + }); + expect(figure.data[1]).toMatchObject({ + customdata: [[20, 12.5, 8]], + hovertemplate: + 'Q3: %{customdata[0]:.1~f}
Mediana: %{customdata[1]:.1~f}
Q1: %{customdata[2]:.1~f}', }); });