Skip to content

Commit 0230b73

Browse files
committed
link up missing axes during setupAxisCategories
... so that if ever a `categoryarray` is set in a missing axis, it gets correctly linked with the other axes in the match group. ++ add image mock!
1 parent 488c35f commit 0230b73

File tree

3 files changed

+340
-5
lines changed

3 files changed

+340
-5
lines changed

src/plots/plots.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,15 +2937,15 @@ plots.doCalcdata = function(gd, traces) {
29372937
calcdata[i] = cd;
29382938
}
29392939

2940-
setupAxisCategories(axList, fullData);
2940+
setupAxisCategories(axList, fullData, fullLayout);
29412941

29422942
// 'transform' loop - must calc container traces first
29432943
// so that if their dependent traces can get transform properly
29442944
for(i = 0; i < fullData.length; i++) calci(i, true);
29452945
for(i = 0; i < fullData.length; i++) transformCalci(i);
29462946

29472947
// clear stuff that should recomputed in 'regular' loop
2948-
if(hasCalcTransform) setupAxisCategories(axList, fullData);
2948+
if(hasCalcTransform) setupAxisCategories(axList, fullData, fullLayout);
29492949

29502950
// 'regular' loop - make sure container traces (eg carpet) calc before
29512951
// contained traces (eg contourcarpet)
@@ -3150,13 +3150,31 @@ function sortAxisCategoriesByValue(axList, gd) {
31503150
return affectedTraces;
31513151
}
31523152

3153-
function setupAxisCategories(axList, fullData) {
3154-
for(var i = 0; i < axList.length; i++) {
3155-
var ax = axList[i];
3153+
function setupAxisCategories(axList, fullData, fullLayout) {
3154+
var axLookup = {};
3155+
var i, ax, axId;
3156+
3157+
for(i = 0; i < axList.length; i++) {
3158+
ax = axList[i];
3159+
axId = ax._id;
3160+
31563161
ax.clearCalc();
31573162
if(ax.type === 'multicategory') {
31583163
ax.setupMultiCategory(fullData);
31593164
}
3165+
3166+
axLookup[ax._id] = 1;
3167+
}
3168+
3169+
// look into match groups for 'missing' axes
3170+
var matchGroups = fullLayout._axisMatchGroups;
3171+
for(i = 0; i < matchGroups.length; i++) {
3172+
for(axId in matchGroups[i]) {
3173+
if(!axLookup[axId]) {
3174+
ax = fullLayout[axisIDs.id2name(axId)];
3175+
ax.clearCalc();
3176+
}
3177+
}
31603178
}
31613179
}
31623180

35.2 KB
Loading
Lines changed: 317 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,317 @@
1+
{
2+
"data": [
3+
{
4+
"type": "bar",
5+
"name": "smoker=No",
6+
"alignmentgroup": "True",
7+
"offsetgroup": "smoker=No",
8+
"legendgroup": "smoker=No",
9+
"showlegend": true,
10+
"marker": { "color": "#636efa" },
11+
"x": [ "Female", "Male", "Male", "Male", "Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female", "Male", "Male", "Female", "Male", "Female", "Male", "Female", "Male", "Male", "Male", "Male", "Male", "Male", "Male", "Male", "Male", "Male", "Female", "Female", "Male", "Male", "Male", "Male", "Male", "Female", "Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female", "Male", "Female", "Female", "Male", "Male", "Male", "Female", "Male", "Male", "Male", "Male", "Male" ],
12+
"y": [ 16.99, 10.34, 21.01, 23.68, 24.59, 25.29, 8.77, 26.88, 15.04, 14.78, 10.27, 35.26, 15.42, 18.43, 14.83, 21.58, 10.33, 16.29, 16.97, 17.46, 13.94, 9.68, 30.4, 18.29, 22.23, 32.4, 28.55, 18.04, 12.54, 10.29, 34.81, 9.94, 25.56, 19.49, 38.07, 23.95, 25.71, 17.31, 29.93, 14.07, 13.13, 17.26, 24.55, 19.77, 29.85, 48.17, 25, 13.39, 16.49, 21.5, 12.66, 16.21, 13.81, 24.52, 20.76, 31.71, 20.69 ],
13+
"xaxis": "x5",
14+
"yaxis": "y5"
15+
},
16+
{
17+
"type": "bar",
18+
"name": "smoker=No",
19+
"alignmentgroup": "True",
20+
"offsetgroup": "smoker=No",
21+
"legendgroup": "smoker=No",
22+
"showlegend": false,
23+
"marker": { "color": "#636efa" },
24+
"x": [ "Male", "Male", "Female", "Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female", "Male", "Male", "Female", "Female", "Male", "Male", "Male", "Female", "Male", "Male", "Male", "Female", "Male", "Male", "Male", "Female", "Male", "Male", "Female", "Female", "Male", "Female", "Male", "Male", "Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female", "Male", "Male" ],
25+
"y": [ 20.65, 17.92, 20.29, 15.77, 39.42, 19.82, 17.81, 13.37, 12.69, 21.7, 19.65, 9.55, 18.35, 15.06, 20.69, 17.78, 24.06, 16.31, 16.93, 18.69, 31.27, 16.04, 26.41, 48.27, 17.59, 20.08, 16.45, 20.23, 12.02, 17.07, 14.73, 10.51, 20.92, 18.24, 14, 7.25, 48.33, 20.45, 13.28, 11.61, 10.77, 10.07, 35.83, 29.03, 17.82 ],
26+
"xaxis": "x6",
27+
"yaxis": "y6"
28+
},
29+
{
30+
"type": "bar",
31+
"name": "smoker=No",
32+
"alignmentgroup": "True",
33+
"offsetgroup": "smoker=No",
34+
"legendgroup": "smoker=No",
35+
"showlegend": false,
36+
"marker": { "color": "#636efa" },
37+
"x": [ "Female" ],
38+
"y": [ 18.78 ],
39+
"xaxis": "x7",
40+
"yaxis": "y7"
41+
},
42+
{
43+
"type": "bar",
44+
"name": "smoker=No",
45+
"alignmentgroup": "True",
46+
"offsetgroup": "smoker=No",
47+
"legendgroup": "smoker=No",
48+
"showlegend": false,
49+
"marker": { "color": "#636efa" },
50+
"x": [ "Male", "Female", "Male" ],
51+
"y": [ 22.49, 22.75, 12.46 ],
52+
"xaxis": "x8",
53+
"yaxis": "y8",
54+
"showlegend": false
55+
},
56+
{
57+
"type": "bar",
58+
"name": "smoker=No",
59+
"alignmentgroup": "True",
60+
"offsetgroup": "smoker=No",
61+
"legendgroup": "smoker=No",
62+
"showlegend": false,
63+
"marker": { "color": "#636efa" },
64+
"x": [ "Male", "Male", "Male", "Male", "Female", "Male", "Female", "Male", "Male", "Male", "Male", "Female", "Female", "Female", "Male", "Female", "Male", "Male", "Female", "Female", "Male", "Female", "Female", "Male", "Male", "Female", "Female", "Female", "Female", "Female", "Female", "Female", "Female", "Female", "Male", "Male", "Female", "Female", "Female", "Female", "Female", "Male", "Male", "Male" ],
65+
"y": [ 27.2, 22.76, 17.29, 16.66, 10.07, 15.98, 34.83, 13.03, 18.28, 24.71, 21.16, 10.65, 12.43, 24.08, 11.69, 13.42, 14.26, 15.95, 12.48, 29.8, 8.52, 14.52, 11.38, 22.82, 19.08, 20.27, 11.17, 12.26, 18.26, 8.51, 10.33, 14.15, 13.16, 17.47, 34.3, 41.19, 27.05, 16.43, 8.35, 18.64, 11.87, 9.78, 7.51, 7.56 ],
66+
"xaxis": "x3",
67+
"yaxis": "y3"
68+
},
69+
{
70+
"type": "bar",
71+
"name": "smoker=No",
72+
"alignmentgroup": "True",
73+
"offsetgroup": "smoker=No",
74+
"legendgroup": "smoker=No",
75+
"showlegend": false,
76+
"marker": { "color": "#636efa" },
77+
"x": [ "Female" ],
78+
"y": [ 15.98 ],
79+
"xaxis": "x4",
80+
"yaxis": "y4"
81+
},
82+
{
83+
"type": "bar",
84+
"name": "smoker=Yes",
85+
"alignmentgroup": "True",
86+
"offsetgroup": "smoker=Yes",
87+
"legendgroup": "smoker=Yes",
88+
"showlegend": true,
89+
"marker": { "color": "#EF553B" },
90+
"x": [ "Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female", "Male", "Male", "Male", "Male", "Male", "Male", "Female", "Male", "Female", "Male", "Male" ],
91+
"y": [ 17.51, 7.25, 31.85, 16.82, 32.9, 17.89, 14.48, 9.6, 34.63, 34.65, 23.33, 45.35, 23.17, 40.55, 20.9, 30.46, 18.15, 23.1, 15.69 ],
92+
"xaxis": "x5",
93+
"yaxis": "y5"
94+
},
95+
{
96+
"type": "bar",
97+
"name": "smoker=Yes",
98+
"alignmentgroup": "True",
99+
"offsetgroup": "smoker=Yes",
100+
"legendgroup": "smoker=Yes",
101+
"showlegend": false,
102+
"marker": { "color": "#EF553B" },
103+
"x": [ "Male", "Male", "Male", "Male", "Male", "Male", "Female", "Male", "Female", "Female", "Male", "Female", "Female", "Male", "Male", "Male", "Female", "Female", "Female", "Male", "Male", "Male", "Male", "Male", "Female", "Male", "Male", "Female", "Female", "Female", "Male", "Male", "Male", "Female", "Female", "Male", "Male", "Male", "Male", "Male", "Female", "Male" ],
104+
"y": [ 38.01, 11.24, 20.29, 13.81, 11.02, 18.29, 3.07, 15.01, 26.86, 25.28, 17.92, 44.3, 22.42, 15.36, 20.49, 25.21, 14.31, 10.59, 10.63, 50.81, 15.81, 26.59, 38.73, 24.27, 12.76, 30.06, 25.89, 13.27, 28.17, 12.9, 28.15, 11.59, 7.74, 30.14, 22.12, 24.01, 15.69, 15.53, 12.6, 32.83, 27.18, 22.67 ],
105+
"xaxis": "x6",
106+
"yaxis": "y6"
107+
},
108+
{
109+
"type": "bar",
110+
"name": "smoker=Yes",
111+
"alignmentgroup": "True",
112+
"offsetgroup": "smoker=Yes",
113+
"legendgroup": "smoker=Yes",
114+
"showlegend": false,
115+
"marker": { "color": "#EF553B" },
116+
"x": [ "Male", "Female", "Female", "Male", "Male", "Male", "Male", "Female", "Female" ],
117+
"y": [ 28.97, 5.75, 16.32, 40.17, 27.28, 12.03, 21.01, 11.35, 15.38 ],
118+
"xaxis": "x8",
119+
"yaxis": "y8"
120+
},
121+
{
122+
"type": "bar",
123+
"name": "smoker=Yes",
124+
"alignmentgroup": "True",
125+
"offsetgroup": "smoker=Yes",
126+
"legendgroup": "smoker=Yes",
127+
"showlegend": false,
128+
"marker": { "color": "#EF553B" },
129+
"x": [ "Male", "Male", "Male", "Female", "Male", "Male", "Male", "Male", "Female", "Female", "Male", "Male", "Female", "Female", "Female", "Male", "Female" ],
130+
"y": [ 19.44, 32.68, 16, 19.81, 28.44, 15.48, 16.58, 10.34, 43.11, 13, 13.51, 18.71, 12.74, 13, 16.4, 20.53, 16.47 ],
131+
"xaxis": "x3",
132+
"yaxis": "y3"
133+
},
134+
{
135+
"type": "bar",
136+
"name": "smoker=Yes",
137+
"alignmentgroup": "True",
138+
"offsetgroup": "smoker=Yes",
139+
"legendgroup": "smoker=Yes",
140+
"showlegend": false,
141+
"marker": { "color": "#EF553B" },
142+
"x": [ "Male", "Female", "Male", "Male", "Female", "Female" ],
143+
"y": [ 12.16, 13.42, 8.58, 13.42, 16.27, 10.09 ],
144+
"xaxis": "x4",
145+
"yaxis": "y4"
146+
}
147+
],
148+
"layout": {
149+
"annotations": [
150+
{
151+
"showarrow": false,
152+
"text": "day=Sun",
153+
"x": 0.11499999999999999,
154+
"xanchor": "center",
155+
"xref": "paper",
156+
"y": 1,
157+
"yanchor": "bottom",
158+
"yref": "paper"
159+
},
160+
{
161+
"showarrow": false,
162+
"text": "day=Sat",
163+
"x": 0.365,
164+
"xanchor": "center",
165+
"xref": "paper",
166+
"y": 1,
167+
"yanchor": "bottom",
168+
"yref": "paper"
169+
},
170+
{
171+
"showarrow": false,
172+
"text": "day=Thur",
173+
"x": 0.615,
174+
"xanchor": "center",
175+
"xref": "paper",
176+
"y": 1,
177+
"yanchor": "bottom",
178+
"yref": "paper"
179+
},
180+
{
181+
"showarrow": false,
182+
"text": "day=Fri",
183+
"x": 0.865,
184+
"xanchor": "center",
185+
"xref": "paper",
186+
"y": 1,
187+
"yanchor": "bottom",
188+
"yref": "paper"
189+
},
190+
{
191+
"showarrow": false,
192+
"text": "time=Lunch",
193+
"textangle": 90,
194+
"x": 0.98,
195+
"xanchor": "left",
196+
"xref": "paper",
197+
"y": 0.2425,
198+
"yanchor": "middle",
199+
"yref": "paper"
200+
},
201+
{
202+
"showarrow": false,
203+
"text": "time=Dinner",
204+
"textangle": 90,
205+
"x": 0.98,
206+
"xanchor": "left",
207+
"xref": "paper",
208+
"y": 0.7575000000000001,
209+
"yanchor": "middle",
210+
"yref": "paper"
211+
}
212+
],
213+
"barmode": "group",
214+
"legend": { "tracegroupgap": 0 },
215+
"margin": { "t": 60 },
216+
"xaxis": {
217+
"anchor": "y",
218+
"domain": [ 0, 0.22999999999999998 ],
219+
"title": { "text": "sex" },
220+
"categoryarray": [ "Male", "Female" ]
221+
},
222+
"xaxis2": {
223+
"anchor": "y2",
224+
"domain": [ 0.24999999999999997, 0.48 ],
225+
"matches": "x",
226+
"title": { "text": "sex" }
227+
},
228+
"xaxis3": {
229+
"anchor": "y3",
230+
"domain": [ 0.49999999999999994, 0.73 ],
231+
"matches": "x",
232+
"title": { "text": "sex" }
233+
},
234+
"xaxis4": {
235+
"anchor": "y4",
236+
"domain": [ 0.75, 0.98 ],
237+
"matches": "x",
238+
"title": { "text": "sex" }
239+
},
240+
"xaxis5": {
241+
"anchor": "y5",
242+
"domain": [ 0, 0.22999999999999998 ],
243+
"matches": "x",
244+
"showticklabels": false
245+
},
246+
"xaxis6": {
247+
"anchor": "y6",
248+
"domain": [ 0.24999999999999997, 0.48 ],
249+
"matches": "x",
250+
"showticklabels": false
251+
},
252+
"xaxis7": {
253+
"anchor": "y7",
254+
"domain": [ 0.49999999999999994, 0.73 ],
255+
"matches": "x",
256+
"showticklabels": false
257+
},
258+
"xaxis8": {
259+
"anchor": "y8",
260+
"domain": [ 0.75, 0.98 ],
261+
"matches": "x",
262+
"showticklabels": false
263+
},
264+
"yaxis": {
265+
"anchor": "x",
266+
"domain": [ 0, 0.485 ],
267+
"title": { "text": "total_bill" }
268+
},
269+
"yaxis2": {
270+
"anchor": "x2",
271+
"domain": [ 0, 0.485 ],
272+
"matches": "y",
273+
"showticklabels": false
274+
},
275+
"yaxis3": {
276+
"anchor": "x3",
277+
"domain": [ 0, 0.485 ],
278+
"matches": "y",
279+
"showticklabels": false
280+
},
281+
"yaxis4": {
282+
"anchor": "x4",
283+
"domain": [ 0, 0.485 ],
284+
"matches": "y",
285+
"showticklabels": false
286+
},
287+
"yaxis5": {
288+
"anchor": "x5",
289+
"domain": [ 0.515, 1 ],
290+
"matches": "y",
291+
"title": { "text": "total_bill" }
292+
},
293+
"yaxis6": {
294+
"anchor": "x6",
295+
"domain": [ 0.515, 1 ],
296+
"matches": "y",
297+
"showticklabels": false
298+
},
299+
"yaxis7": {
300+
"anchor": "x7",
301+
"domain": [ 0.515, 1 ],
302+
"matches": "y",
303+
"showticklabels": false
304+
},
305+
"yaxis8": {
306+
"anchor": "x8",
307+
"domain": [ 0.515, 1 ],
308+
"matches": "y",
309+
"showticklabels": false
310+
},
311+
"title": {
312+
"text" : "Matching missing axes 'x' and 'y'<br>with categoryarray set in xaxis",
313+
"x": 0.05,
314+
"y": 0.2
315+
}
316+
}
317+
}

0 commit comments

Comments
 (0)