Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit edfa543

Browse files
committed
simplify sizemode usage
1 parent 44e1355 commit edfa543

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/traces/box/plot.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function plotBoxAndWhiskers(sel, axes, trace, t, isStatic) {
5454
var wdPos = t.wdPos || 0;
5555
var bPosPxOffset = t.bPosPxOffset || 0;
5656
var whiskerWidth = trace.whiskerwidth || 0;
57-
var showWhiskers = trace.showwhiskers;
57+
var showWhiskers = (trace.showwhiskers !== false);
5858
var notched = trace.notched || false;
5959
var nw = notched ? 1 - 2 * trace.notchwidth : 1;
6060

@@ -97,13 +97,13 @@ function plotBoxAndWhiskers(sel, axes, trace, t, isStatic) {
9797
var posm1 = posAxis.l2p(lcenter + bdPos1 * nw) + bPosPxOffset;
9898
var sdmode = trace.sizemode === 'sd';
9999
var q1 = valAxis.c2p(sdmode ? d.mean - d.sd : d.q1, true);
100-
var q3 = trace.sizemode === 'sd' ? valAxis.c2p(d.mean + 1 * d.sd, true) :
101-
valAxis.c2p(d.q3, true);
100+
var q3 = sdmode ? valAxis.c2p(d.mean + d.sd, true) :
101+
valAxis.c2p(d.q3, true);
102102
// make sure median isn't identical to either of the
103103
// quartiles, so we can see it
104104
var m = Lib.constrain(
105-
trace.sizemode === 'sd' ? valAxis.c2p(d.mean, true) :
106-
valAxis.c2p(d.med, true),
105+
sdmode ? valAxis.c2p(d.mean, true) :
106+
valAxis.c2p(d.med, true),
107107
Math.min(q1, q3) + 1, Math.max(q1, q3) - 1
108108
);
109109

@@ -113,7 +113,7 @@ function plotBoxAndWhiskers(sel, axes, trace, t, isStatic) {
113113
// - box always has d.lf, but boxpoints can be anything
114114
// - violin has d.lf and should always use it (boxpoints is undefined)
115115
// - candlestick has only min/max
116-
var useExtremes = (d.lf === undefined) || (trace.boxpoints === false) || (trace.sizemode === 'sd');
116+
var useExtremes = (d.lf === undefined) || (trace.boxpoints === false) || sdmode;
117117
var lf = valAxis.c2p(useExtremes ? d.min : d.lf, true);
118118
var uf = valAxis.c2p(useExtremes ? d.max : d.uf, true);
119119
var ln = valAxis.c2p(d.ln, true);

0 commit comments

Comments
 (0)