Skip to content

Commit 9b72c48

Browse files
authored
Merge pull request #2267
* [#CODAP-899] Bug fix: Box plot median is hidden when equal to Q1 * * Code review tweak
1 parent 54cd2f1 commit 9b72c48

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

v3/src/components/graph/adornments/univariate-measures/box-plot/box-plot-adornment-component.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,25 @@ export const BoxPlotAdornmentComponent = observer(function BoxPlotAdornmentCompo
411411
const translationVars = [ minWhiskerValue, lowerQuartile, median, upperQuartile, maxWhiskerValue, iqr ]
412412
.map(v => helper.formatValueForScale(v))
413413
let textContent = `${t(model.labelTitle, { vars: translationVars })}`
414+
// Special case in which median equals lower and/or upper quartile
415+
// We combine the labels for those two or three measures so the user sees all info
416+
// Todo: We're not handling the situation in which the measures are very close to each other.
417+
// Consider basing equality on the threshold of one pixel difference
418+
// Todo: We're also not handling equality of min/max whisker with quartiles or median. (Not a common case.)
419+
if (lowerQuartile === median || median === upperQuartile) {
420+
const contentArray = textContent.split("\n")
421+
if (lowerQuartile === median && median === upperQuartile) {
422+
// It turns out the third array element is the one that displays in this situation
423+
contentArray[3] = `${contentArray[1]}; ${contentArray[2]}; ${contentArray[3]}`
424+
}
425+
else if (lowerQuartile === median) {
426+
contentArray[1] = `${contentArray[1]}; ${contentArray[2]}`
427+
}
428+
else if (median === upperQuartile) {
429+
contentArray[3] = `${contentArray[2]}; ${contentArray[3]}`
430+
}
431+
textContent = contentArray.join("\n")
432+
}
414433

415434
if ((measureRange?.min || measureRange?.min === 0) && (measureRange?.max || measureRange?.max === 0)) {
416435
const rangeSpecs = {

0 commit comments

Comments
 (0)