Skip to content

Commit e56020d

Browse files
committed
Redraw if needed based on shift param
1 parent ec1f855 commit e56020d

File tree

2 files changed

+112
-1
lines changed

2 files changed

+112
-1
lines changed

src/plots/plots.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,21 @@ plots.autoMargin = function(gd, id, o) {
19551955
}
19561956
};
19571957

1958+
plots.redrawWithShift = function(gd) {
1959+
if('_redrawFromAutoMarginCount' in gd._fullLayout) {
1960+
return false
1961+
}
1962+
var axList = axisIDs.list(gd, '', true)
1963+
var isShift = false;
1964+
for(var ax in axList) {
1965+
if(isShift === true){
1966+
return isShift;
1967+
}
1968+
isShift = axList[ax].shift
1969+
}
1970+
return isShift
1971+
}
1972+
19581973
plots.doAutoMargin = function(gd) {
19591974
var fullLayout = gd._fullLayout;
19601975
var width = fullLayout.width;
@@ -2073,7 +2088,7 @@ plots.doAutoMargin = function(gd) {
20732088
gs.h = Math.round(height) - gs.t - gs.b;
20742089

20752090
// if things changed and we're not already redrawing, trigger a redraw
2076-
if(!fullLayout._replotting && plots.didMarginChange(oldMargins, gs)) {
2091+
if(!fullLayout._replotting && (plots.didMarginChange(oldMargins, gs) || plots.redrawWithShift(gd))) {
20772092
if('_redrawFromAutoMarginCount' in fullLayout) {
20782093
fullLayout._redrawFromAutoMarginCount++;
20792094
} else {
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
4,
25+
5,
26+
6
27+
],
28+
"name": "yaxis2 data",
29+
"yaxis": "y2",
30+
"type": "scatter"
31+
},
32+
{
33+
"x": [
34+
3,
35+
4,
36+
5
37+
],
38+
"y": [
39+
4,
40+
5,
41+
6
42+
],
43+
"name": "yaxis3 data",
44+
"yaxis": "y3",
45+
"type": "scatter"
46+
},
47+
{
48+
"x": [
49+
4,
50+
5,
51+
6
52+
],
53+
"y": [
54+
1,
55+
2,
56+
3
57+
],
58+
"name": "yaxis4 data",
59+
"yaxis": "y4",
60+
"type": "scatter"
61+
}
62+
],
63+
"layout": {
64+
"title": {
65+
"text": "multiple y-axes example"
66+
},
67+
"xaxis": {"domain": [0.25, 0.75]},
68+
"width": 800,
69+
"yaxis": {
70+
"showline": true,
71+
"title": {"text": "axis 1"}
72+
},
73+
"yaxis2": {
74+
"overlaying": "y",
75+
"showline": true,
76+
"side": "right",
77+
"title": {"text": "axis 2"}
78+
},
79+
"yaxis3": {
80+
"anchor": "free",
81+
"overlaying": "y",
82+
"showline": true,
83+
"shift": true,
84+
"side": "right",
85+
"title": {"text": "axis 3"}
86+
},
87+
"yaxis4": {
88+
"anchor": "free",
89+
"overlaying": "y",
90+
"showline": true,
91+
"shift": true,
92+
"side": "left",
93+
"title": {"text": "axis 4"}
94+
}
95+
}
96+
}

0 commit comments

Comments
 (0)