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

Skip to content

Commit c802d32

Browse files
committed
fix box/violin x0/y0 multi-category edge case
1 parent 3eac338 commit c802d32

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed

src/traces/box/calc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@ function getPos(trace, posLetter, posAxis, val, num) {
178178
pos0 = num;
179179
}
180180

181-
// TODO what to do on multicategory posAxis?
182-
var pos0c = posAxis.d2c(pos0, 0, trace[posLetter + 'calendar']);
181+
var pos0c = posAxis.type === 'multicategory' ?
182+
posAxis.r2c(pos0) :
183+
posAxis.d2c(pos0, 0, trace[posLetter + 'calendar']);
184+
183185
return val.map(function() { return pos0c; });
184186
}
185187

Loading
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"data": [
3+
{
4+
"y": [ 0.2, 0.2, 0.6, 1, 0.5, 0.4, 0.2, 0.7, 0.9, 0.1, 0.5, 0.3, 0.6, 0.7, 0.3, 0.6, 0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2 ],
5+
"x": [
6+
[ "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016",
7+
"2017", "2017", "2017", "2017", "2017", "2017", "2017", "2017", "2017", "2017", "2017", "2017"
8+
],
9+
[ "day 1", "day 1", "day 1", "day 1", "day 1", "day 1",
10+
"day 2", "day 2", "day 2", "day 2", "day 2", "day 2",
11+
"day 1", "day 1", "day 1", "day 1", "day 1", "day 1",
12+
"day 2", "day 2", "day 2", "day 2", "day 2", "day 2"
13+
]
14+
],
15+
"type": "box"
16+
},
17+
{
18+
"y": [ 0.6, 0.7, 0.3, 0.6, 0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2, 0.1, 0.3, 0.1, 0.9, 0.6, 0.6, 0.9, 1, 0.3, 0.6, 0.8, 0.5, 0.6, 0.7, 0.3, 0.6, 0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2 ],
19+
"x0": 0.5,
20+
"type": "violin"
21+
},
22+
{
23+
"y": [ 0.2, 0.2, 0.6, 1, 0.5, 0.4, 0.2, 0.7, 0.9, 0.1, 0.5, 0.3, 0.6, 0.7, 0.3, 0.6, 0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2 ],
24+
"x": [ "day 1", "day 1", "day 1", "day 1", "day 1", "day 1", "day 2",
25+
"day 2", "day 2", "day 2", "day 2", "day 2",
26+
"day 1", "day 1", "day 1", "day 1", "day 1", "day 1",
27+
"day 2", "day 2", "day 2", "day 2", "day 2", "day 2"
28+
],
29+
"type": "box",
30+
"xaxis": "x2",
31+
"yaxis": "y2"
32+
},
33+
{
34+
"y": [ 0.6, 0.7, 0.3, 0.6, 0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2, 0.1, 0.3, 0.1, 0.9, 0.6, 0.6, 0.9, 1, 0.3, 0.6, 0.8, 0.5, 0.6, 0.7, 0.3, 0.6, 0, 0.5, 0.7, 0.9, 0.5, 0.8, 0.7, 0.2 ],
35+
"x0": "day 2",
36+
"type": "violin",
37+
"xaxis": "x2",
38+
"yaxis": "y2"
39+
}
40+
],
41+
"layout": {
42+
"grid": {
43+
"rows": 2,
44+
"columns": 1,
45+
"pattern": "independent"
46+
},
47+
"annotations": [
48+
{
49+
"xref": "x",
50+
"yref": "y",
51+
"x": 0.5,
52+
"text": "violin at x0:0.5",
53+
"y": 1.5
54+
},
55+
{
56+
"xref": "x2",
57+
"yref": "y2",
58+
"x": "day 2",
59+
"text": "box at x0:\"day 2\"",
60+
"y": 1.5
61+
}
62+
],
63+
"showlegend": false
64+
}
65+
}

0 commit comments

Comments
 (0)