diff --git a/src/marks/box.js b/src/marks/box.js index 8bc8a7fbfa..f87d061115 100644 --- a/src/marks/box.js +++ b/src/marks/box.js @@ -34,7 +34,7 @@ export function boxX( barX(data, group({x1: "p25", x2: "p75"}, {x, y, fill, fillOpacity, ...options})), tickX(data, group({x: "p50"}, {x, y, stroke, strokeOpacity, strokeWidth, sort, ...options})), dot(data, map({x: oqr}, {x, y, z: y, stroke, strokeOpacity, ...options})), - tip && tipmark(data, pointerY(group({x: "median", title: boxStats}, {x, y, z: y, title: x, ...options}))) + tip && tipmark(data, pointerY(group({x: "p50", title: boxStats}, {x, y, z: y, title: x, ...options}))) ); } @@ -61,7 +61,7 @@ export function boxY( barY(data, group({y1: "p25", y2: "p75"}, {x, y, fill, fillOpacity, ...options})), tickY(data, group({y: "p50"}, {x, y, stroke, strokeOpacity, strokeWidth, sort, ...options})), dot(data, map({y: oqr}, {x, y, z: x, stroke, strokeOpacity, ...options})), - tip && tipmark(data, pointerX(group({y: "median", title: boxStats}, {x, y, z: x, title: y, ...options}))) + tip && tipmark(data, pointerX(group({y: "p50", title: boxStats}, {x, y, z: x, title: y, ...options}))) ); } @@ -109,41 +109,15 @@ function boxStats(values) { break; } } - let _loqr1 = 0; - let _hiqr2 = 0; - let _q1 = 0; - let _q2 = 0; - let _q3 = 0; - for (const d of V) { - switch (true) { - case d < loqr1: - _loqr1++; - // eslint-disable-next-line no-fallthrough - case d <= q1: - _q1++; - // eslint-disable-next-line no-fallthrough - case d <= q2: - _q2++; - // eslint-disable-next-line no-fallthrough - case d <= q3: - _q3++; - // eslint-disable-next-line no-fallthrough - case d <= hiqr2: - break; - default: - _hiqr2++; - } - } const f = formatDefault; return ( q1 === q3 ? [f(q2)] : [ - loqr1 < q2 && `${f(_loqr1)}# < ${f(loqr1)}`, - q1 < q2 && `${_q1}# ≤ ${f(q1)}`, - `${_q2}# ≤ ${f(q2)}`, - q3 > q2 && `${_q3}# ≤ ${f(q3)}`, - hiqr2 > q2 && `${f(_hiqr2)}# > ${f(hiqr2)}` + q1 < q2 && `p25: ${f(q1)}`, + `p50: ${f(q2)}`, + q3 > q2 && `p75: ${f(q3)}`, + loqr1 < hiqr2 && `[${f(loqr1)} — ${f(hiqr2)}]` ] ) .filter((d) => d)