Box charts hover only Q3, Mediana and Q1, through an invisible marker; the box itself takes no hover
This commit is contained in:
@@ -287,8 +287,17 @@ export function boxFigure(r: Reading, period: string): Figure {
|
|||||||
upperfence: [q3],
|
upperfence: [q3],
|
||||||
marker: { color: '#4269C2' },
|
marker: { color: '#4269C2' },
|
||||||
fillcolor: 'rgba(66,105,194,0.55)',
|
fillcolor: 'rgba(66,105,194,0.55)',
|
||||||
hovertemplate: `Q3: %{q3:${SHORT}}<br>Mediana: %{median:${SHORT}}<br>Q1: %{q1:${SHORT}}<extra></extra>`,
|
hoverinfo: 'skip',
|
||||||
} as Partial<Plotly.Data>,
|
} as Partial<Plotly.Data>,
|
||||||
|
{
|
||||||
|
type: 'scatter',
|
||||||
|
mode: 'markers',
|
||||||
|
x: [period],
|
||||||
|
y: [r.score!],
|
||||||
|
customdata: [[q3, r.score!, q1]],
|
||||||
|
marker: { size: 40, opacity: 0 },
|
||||||
|
hovertemplate: `Q3: %{customdata[0]:${SHORT}}<br>Mediana: %{customdata[1]:${SHORT}}<br>Q1: %{customdata[2]:${SHORT}}<extra></extra>`,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
layout: {
|
layout: {
|
||||||
showlegend: false,
|
showlegend: false,
|
||||||
|
|||||||
@@ -409,7 +409,12 @@ describe('TEA clinical figures', () => {
|
|||||||
q1: [8],
|
q1: [8],
|
||||||
median: [12.5],
|
median: [12.5],
|
||||||
q3: [20],
|
q3: [20],
|
||||||
hovertemplate: 'Q3: %{q3:.1~f}<br>Mediana: %{median:.1~f}<br>Q1: %{q1:.1~f}<extra></extra>',
|
hoverinfo: 'skip',
|
||||||
|
});
|
||||||
|
expect(figure.data[1]).toMatchObject({
|
||||||
|
customdata: [[20, 12.5, 8]],
|
||||||
|
hovertemplate:
|
||||||
|
'Q3: %{customdata[0]:.1~f}<br>Mediana: %{customdata[1]:.1~f}<br>Q1: %{customdata[2]:.1~f}<extra></extra>',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user