Skip to content

Commit e468f04

Browse files
committed
refactor box plot
1 parent 13947fc commit e468f04

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/traces/box/plot.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,26 +119,41 @@ function plotBoxAndWhiskers(sel, axes, trace, t) {
119119
d3.select(this).attr('d',
120120
'M' + m + ',' + posm0 + 'V' + posm1 + // median line
121121
'M' + q1 + ',' + pos0 + 'V' + pos1 + // left edge
122-
(notched ? 'H' + ln + 'L' + m + ',' + posm1 + 'L' + un + ',' + pos1 : '') + // top notched edge
122+
(notched ?
123+
'H' + ln + 'L' + m + ',' + posm1 + 'L' + un + ',' + pos1 :
124+
''
125+
) + // top notched edge
123126
'H' + q3 + // end of the top edge
124127
'V' + pos0 + // right edge
125128
(notched ? 'H' + un + 'L' + m + ',' + posm0 + 'L' + ln + ',' + pos0 : '') + // bottom notched edge
126129
'Z' + // end of the box
127130
'M' + q1 + ',' + posc + 'H' + lf + 'M' + q3 + ',' + posc + 'H' + uf + // whiskers
128-
((whiskerWidth === 0) ? '' : // whisker caps
129-
'M' + lf + ',' + posw0 + 'V' + posw1 + 'M' + uf + ',' + posw0 + 'V' + posw1));
131+
(whiskerWidth === 0 ?
132+
'' : // whisker caps
133+
'M' + lf + ',' + posw0 + 'V' + posw1 + 'M' + uf + ',' + posw0 + 'V' + posw1
134+
)
135+
);
130136
} else {
131137
d3.select(this).attr('d',
132138
'M' + posm0 + ',' + m + 'H' + posm1 + // median line
133139
'M' + pos0 + ',' + q1 + 'H' + pos1 + // top of the box
134-
(notched ? 'V' + ln + 'L' + posm1 + ',' + m + 'L' + pos1 + ',' + un : '') + // notched right edge
140+
(notched ?
141+
'V' + ln + 'L' + posm1 + ',' + m + 'L' + pos1 + ',' + un :
142+
''
143+
) + // notched right edge
135144
'V' + q3 + // end of the right edge
136145
'H' + pos0 + // bottom of the box
137-
(notched ? 'V' + un + 'L' + posm0 + ',' + m + 'L' + pos0 + ',' + ln : '') + // notched left edge
146+
(notched ?
147+
'V' + un + 'L' + posm0 + ',' + m + 'L' + pos0 + ',' + ln :
148+
''
149+
) + // notched left edge
138150
'Z' + // end of the box
139151
'M' + posc + ',' + q1 + 'V' + lf + 'M' + posc + ',' + q3 + 'V' + uf + // whiskers
140-
((whiskerWidth === 0) ? '' : // whisker caps
141-
'M' + posw0 + ',' + lf + 'H' + posw1 + 'M' + posw0 + ',' + uf + 'H' + posw1));
152+
(whiskerWidth === 0 ?
153+
'' : // whisker caps
154+
'M' + posw0 + ',' + lf + 'H' + posw1 + 'M' + posw0 + ',' + uf + 'H' + posw1
155+
)
156+
);
142157
}
143158
});
144159
}

0 commit comments

Comments
 (0)