Skip to content

Commit a237252

Browse files
committed
fix one-sided + set width violin axis-expand case
1 parent c1d6e76 commit a237252

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

Diff for: src/traces/box/cross_trace_calc.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ function setPositionOffset(traceType, gd, boxList, posAxis) {
128128
var edgeminus;
129129

130130
if(side === 'positive') {
131-
pushplus = dPos / 2;
131+
pushplus = dPos * (width ? 1 : 0.5);
132132
edgeplus = edge;
133133
pushminus = edgeplus = bPos;
134134
} else if(side === 'negative') {
135135
pushplus = edgeplus = bPos;
136-
pushminus = dPos / 2;
136+
pushminus = dPos * (width ? 1 : 0.5);
137137
edgeminus = edge;
138138
} else {
139139
pushplus = pushminus = dPos;
@@ -193,7 +193,6 @@ function setPositionOffset(traceType, gd, boxList, posAxis) {
193193
// (<-) fallback to push value
194194
vpadminus = pushminus;
195195
}
196-
197196
} else {
198197
vpadplus = pushplus;
199198
vpadminus = pushminus;

Diff for: test/image/baselines/violin_box_multiple_widths.png

8.65 KB
Loading

Diff for: test/image/mocks/violin_box_multiple_widths.json

+17-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,25 @@
3434
"fillcolor": "#c78dd3",
3535
"opacity": 0.6,
3636
"y0": 0.2
37+
}, {
38+
"type": "violin",
39+
"width": 0.4,
40+
"name": "width: 0.4 (solo)",
41+
"x": [0, 5, 7, 8],
42+
"side": "positive",
43+
"line": {
44+
"color": "black"
45+
},
46+
"fillcolor": "#8dd3c7",
47+
"opacity": 0.6,
48+
"y0": 0.0,
49+
"xaxis": "x2",
50+
"yaxis": "y2"
3751
}],
3852
"layout": {
39-
"title": "Violins/boxes - with multiple widths",
40-
"legend": {"x": 0},
53+
"grid": {"rows": 1, "columns": 2, "pattern": "independent"},
54+
"title": {"text" :"Violins/boxes - with multiple widths", "x": 0, "xref": "paper"},
55+
"legend": {"x": 1, "y": 1, "xanchor": "right", "yanchor": "bottom"},
4156
"xaxis": {"zeroline": false},
4257
"yaxis": {"dtick": 0.1, "gridcolor": "black"}
4358
}

0 commit comments

Comments
 (0)