Skip to content

Commit f013426

Browse files
committed
Add mock and exploratory code
1 parent 259c942 commit f013426

File tree

4 files changed

+91
-10
lines changed

4 files changed

+91
-10
lines changed

src/plot_api/subroutines.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,3 +713,15 @@ exports.drawMarginPushers = function(gd) {
713713
Registry.getComponentMethod('updatemenus', 'draw')(gd);
714714
Registry.getComponentMethod('colorbar', 'draw')(gd);
715715
};
716+
717+
// function getAxDepth(ax) {
718+
// var depth = null;
719+
// if (ax.type == 'multicategory') {
720+
// depth = majorTickSigns[4] * (getLabelLevelBbox('tick2')[ax.side] - mainLinePosition);
721+
722+
// } else if(ax.title.hasOwnProperty('standoff')) {
723+
// depth = majorTickSigns[4] * (getLabelLevelBbox()[ax.side] - mainLinePosition);
724+
// }
725+
726+
// }
727+

src/plots/cartesian/axes.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,16 +2248,23 @@ axes.draw = function(gd, arg, opts) {
22482248

22492249
var axList = (!arg || arg === 'redraw') ? axes.listIds(gd) : arg;
22502250

2251+
var allDepths = [0] // Or dict w keys/values?
2252+
22512253
return Lib.syncOrAsync(axList.map(function(axId) {
22522254
return function() {
22532255
if(!axId) return;
22542256

22552257
var ax = axes.getFromId(gd, axId);
2256-
var axDone = axes.drawOne(gd, ax, opts);
2258+
var axDone = axes.drawOne(gd, ax, opts, allDepths);
22572259

2260+
var depth = ax._depth
2261+
console.log(depth)
2262+
//var depthPrev = allDepths.pop
2263+
allDepths.push(depth)
2264+
22582265
ax._r = ax.range.slice();
22592266
ax._rl = Lib.simpleMap(ax._r, ax.r2l);
2260-
2267+
//debugger;
22612268
return axDone;
22622269
};
22632270
}));
@@ -2290,11 +2297,12 @@ axes.draw = function(gd, arg, opts) {
22902297
* - ax._depth (when required only):
22912298
* - and calls ax.setScale
22922299
*/
2293-
axes.drawOne = function(gd, ax, opts) {
2300+
axes.drawOne = function(gd, ax, opts, allDepths) {
2301+
//debugger;
22942302
opts = opts || {};
22952303

22962304
var i, sp, plotinfo;
2297-
2305+
console.log(allDepths)
22982306
ax.setScale();
22992307

23002308
var fullLayout = gd._fullLayout;
@@ -2541,6 +2549,7 @@ axes.drawOne = function(gd, ax, opts) {
25412549
var s = ax.side.charAt(0);
25422550
var sMirror = OPPOSITE_SIDE[ax.side].charAt(0);
25432551
var pos = axes.getPxPosition(gd, ax);
2552+
console.log(pos)
25442553
var outsideTickLen = outsideTicks ? ax.ticklen : 0;
25452554
var llbbox;
25462555

@@ -2646,7 +2655,7 @@ axes.drawOne = function(gd, ax, opts) {
26462655
) {
26472656
seq.push(function() { return drawTitle(gd, ax); });
26482657
}
2649-
2658+
console.log(seq)
26502659
return Lib.syncOrAsync(seq);
26512660
};
26522661

@@ -3764,7 +3773,7 @@ function drawDividers(gd, ax, opts) {
37643773
* - {number} position
37653774
* @return {number}
37663775
*/
3767-
axes.getPxPosition = function(gd, ax) {
3776+
axes.getPxPosition = function(gd, ax, offset) {
37683777
var gs = gd._fullLayout._size;
37693778
var axLetter = ax._id.charAt(0);
37703779
var side = ax.side;

test/image/mocks/multiple_axes_multiple.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
"color": "#1f77b4"
8181
},
8282
"text": "yaxis title"
83-
}
83+
},
84+
"automargin": true
8485
},
8586
"yaxis2": {
8687
"title": {
@@ -95,7 +96,8 @@
9596
"anchor": "free",
9697
"side": "left",
9798
"position": 0.15,
98-
"overlaying": "y"
99+
"overlaying": "y",
100+
"automargin": true
99101
},
100102
"yaxis3": {
101103
"title": {
@@ -109,7 +111,8 @@
109111
},
110112
"anchor": "x",
111113
"side": "right",
112-
"overlaying": "y"
114+
"overlaying": "y",
115+
"automargin": true
113116
},
114117
"yaxis4": {
115118
"title": {
@@ -124,7 +127,8 @@
124127
"anchor": "free",
125128
"side": "right",
126129
"position": 0.85,
127-
"overlaying": "y"
130+
"overlaying": "y",
131+
"automargin": true
128132
}
129133
}
130134
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"data": [
3+
{
4+
"x": [
5+
1,
6+
2,
7+
3
8+
],
9+
"y": [
10+
4,
11+
5,
12+
6
13+
],
14+
"name": "yaxis1 data",
15+
"type": "scatter"
16+
},
17+
{
18+
"x": [
19+
2,
20+
3,
21+
4
22+
],
23+
"y": [
24+
40,
25+
50,
26+
60
27+
],
28+
"name": "yaxis2 data",
29+
"yaxis": "y2",
30+
"type": "scatter"
31+
}
32+
],
33+
"layout": {
34+
"title": {
35+
"text": "multiple y-axes example"
36+
},
37+
"width": 800,
38+
"xaxis": {
39+
"domain": [
40+
0.5,
41+
1
42+
]
43+
},
44+
"yaxis": {
45+
"title": {"text": "yaxis title"},
46+
"automargin": true,
47+
"anchor": "free"
48+
},
49+
"yaxis2": {
50+
"title": {"text": "yaxis2 title"},
51+
"anchor": "free",
52+
"overlaying": "y",
53+
"automargin": true
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)