Skip to content

Commit 5ef2eeb

Browse files
change dflt vwidth to 0;assign dPos for each trace
1 parent 81cdbe9 commit 5ef2eeb

File tree

5 files changed

+33
-24
lines changed

5 files changed

+33
-24
lines changed

src/traces/box/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ module.exports = {
244244
marker: scatterAttrs.unselected.marker,
245245
editType: 'style'
246246
},
247-
248247
hoveron: {
249248
valType: 'flaglist',
250249
flags: ['boxes', 'points'],
@@ -267,4 +266,5 @@ module.exports = {
267266
'This overrides the normal width of the box traces.'
268267
].join(' ')
269268
},
269+
270270
};

src/traces/box/cross_trace_calc.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ function crossTraceCalc(gd, plotinfo) {
4848
}
4949
}
5050

51-
setPositionOffset('box', gd, boxList, posAxis, [minPad, maxPad], false);
51+
setPositionOffset('box', gd, boxList, posAxis, [minPad, maxPad]);
5252
}
5353
}
5454

55-
function setPositionOffset(traceType, gd, boxList, posAxis, pad, vwidth) {
55+
function setPositionOffset(traceType, gd, boxList, posAxis, pad) {
5656
var calcdata = gd.calcdata;
5757
var fullLayout = gd._fullLayout;
5858
var pointList = [];
@@ -77,11 +77,6 @@ function setPositionOffset(traceType, gd, boxList, posAxis, pad, vwidth) {
7777
var boxdv = Lib.distinctVals(pointList);
7878
var dPos = boxdv.minDiff / 2;
7979

80-
// override dPos if violin width given
81-
if(vwidth) {
82-
dPos = vwidth;
83-
}
84-
8580
// if there's no duplication of x points,
8681
// disable 'group' mode by setting counter to 1
8782
if(pointList.length === boxdv.vals.length) {
@@ -105,8 +100,15 @@ function setPositionOffset(traceType, gd, boxList, posAxis, pad, vwidth) {
105100

106101
for(i = 0; i < boxList.length; i++) {
107102
calcTrace = calcdata[boxList[i]];
108-
// set the width of all boxes
109-
calcTrace[0].t.dPos = dPos;
103+
// set the width of all boxes and
104+
// override this width with
105+
// trace.width if it exists
106+
if(calcTrace[0].trace && calcTrace[0].trace.vwidth) {
107+
calcTrace[0].t.dPos = calcTrace[0].trace.vwidth;
108+
} else {
109+
calcTrace[0].t.dPos = dPos;
110+
}
111+
110112
// link extremes to all boxes
111113
calcTrace[0].trace._extremes[posAxis._id] = extremes;
112114
}

src/traces/box/defaults.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
2828

2929
coerce('whiskerwidth');
3030
coerce('boxmean');
31-
coerce('vwidth');
31+
32+
// coerce('vwidth');
33+
var vwidth = coerce('vwidth');
34+
if(!vwidth) {
35+
coerce('scalegroup', traceOut.name);
36+
coerce('scalemode');
37+
}
3238

3339
var notched = coerce('notched', traceIn.notchwidth !== undefined);
3440
if(notched) coerce('notchwidth');

src/traces/violin/attributes.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@ var boxAttrs = require('../box/attributes');
1212
var extendFlat = require('../../lib/extend').extendFlat;
1313

1414
module.exports = {
15-
vwidth: {
16-
valType: 'number',
17-
min: 0,
18-
role: 'info',
19-
dflt: 0,
20-
editType: 'calc',
21-
description: [
22-
'Sets the width of the violins.',
23-
'This overrides the normal width of the violins.'
24-
].join(' ')
25-
},
2615
y: boxAttrs.y,
2716
x: boxAttrs.x,
2817
x0: boxAttrs.x0,
@@ -254,5 +243,17 @@ module.exports = {
254243
'Do the hover effects highlight individual violins',
255244
'or sample points or the kernel density estimate or any combination of them?'
256245
].join(' ')
257-
}
246+
},
247+
248+
vwidth: {
249+
valType: 'number',
250+
min: 0,
251+
role: 'info',
252+
dflt: 0,
253+
editType: 'calc',
254+
description: [
255+
'Sets the width of the violins.',
256+
'This overrides the normal width of the violins.'
257+
].join(' ')
258+
},
258259
};

src/traces/violin/cross_trace_calc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ module.exports = function crossTraceCalc(gd, plotinfo) {
4343
}
4444
}
4545

46-
setPositionOffset('violin', gd, violinList, posAxis, [minPad, maxPad], trace.vwidth);
46+
setPositionOffset('violin', gd, violinList, posAxis, [minPad, maxPad]);
4747
}
4848
};

0 commit comments

Comments
 (0)