-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle case of nonnegative or tozero rangemodes for inside ticklabels #5331
Changes from 1 commit
bc38ade
f31d97c
be762b6
15b002a
0b254e7
4bb0995
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,8 +226,13 @@ function makePadFn(fullLayout, ax, max) { | |
var A = 0; | ||
var B = 0; | ||
if(!isLinked(fullLayout, ax._id)) { | ||
A = padInsideLabelsOnAnchorAxis(ax, max); | ||
B = padInsideLabelsOnThisAxis(ax, max); | ||
if(ax.rangemode !== 'nonnegative') { | ||
A = padInsideLabelsOnAnchorAxis(ax, max); | ||
|
||
if(anchorAxis.rangemode !== 'nonnegative') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why would There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. Fixed in f31d97c. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait. I had to revert the commit. |
||
B = padInsideLabelsOnThisAxis(ax, max); | ||
} | ||
} | ||
} | ||
|
||
var zero = Math.max(A, B); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
{ | ||
"data": [{ | ||
"xaxis": "x", | ||
"yaxis": "y", | ||
"type": "bar", | ||
"orientation": "h", | ||
"x": [ | ||
67.5, | ||
23.3, | ||
5.2, | ||
1.8, | ||
0.8, | ||
0.7, | ||
0.23, | ||
0.1, | ||
0.1 | ||
], | ||
"y": [ | ||
"Hydro", | ||
"Solid biomass", | ||
"Wind", | ||
"Ethanol", | ||
"Renewable municipal waste", | ||
"Solar thermal", | ||
"Biodiesel", | ||
"Solar photovoltaic", | ||
"Tidal" | ||
] | ||
}, { | ||
"xaxis": "x2", | ||
"yaxis": "y2", | ||
"type": "bar", | ||
"orientation": "h", | ||
"x": [ | ||
67.5, | ||
23.3, | ||
5.2, | ||
1.8, | ||
0.8, | ||
0.7, | ||
0.23, | ||
0.1, | ||
0.1 | ||
], | ||
"y": [ | ||
"Hydro", | ||
"Solid biomass", | ||
"Wind", | ||
"Ethanol", | ||
"Renewable municipal waste", | ||
"Solar thermal", | ||
"Biodiesel", | ||
"Solar photovoltaic", | ||
"Tidal" | ||
] | ||
}, { | ||
"xaxis": "x3", | ||
"yaxis": "y3", | ||
"type": "bar", | ||
"orientation": "v", | ||
"y": [ | ||
67.5, | ||
23.3, | ||
5.2, | ||
1.8, | ||
0.8, | ||
0.7, | ||
0.23, | ||
0.1, | ||
0.1 | ||
], | ||
"x": [ | ||
"Hydro", | ||
"Solid biomass", | ||
"Wind", | ||
"Ethanol", | ||
"Renewable municipal waste", | ||
"Solar thermal", | ||
"Biodiesel", | ||
"Solar photovoltaic", | ||
"Tidal" | ||
] | ||
}, { | ||
"xaxis": "x4", | ||
"yaxis": "y4", | ||
"type": "bar", | ||
"orientation": "v", | ||
"y": [ | ||
67.5, | ||
23.3, | ||
5.2, | ||
1.8, | ||
0.8, | ||
0.7, | ||
0.23, | ||
0.1, | ||
0.1 | ||
], | ||
"x": [ | ||
"Hydro", | ||
"Solid biomass", | ||
"Wind", | ||
"Ethanol", | ||
"Renewable municipal waste", | ||
"Solar thermal", | ||
"Biodiesel", | ||
"Solar photovoltaic", | ||
"Tidal" | ||
] | ||
}], | ||
"layout": { | ||
"xaxis": { | ||
"rangemode": "nonnegative", | ||
"anchor": "y", | ||
"domain": [0, 0.475], | ||
"side": "bottom", | ||
"ticklabelposition": "outside", | ||
"gridcolor": "white" | ||
}, | ||
"yaxis": { | ||
"anchor": "x", | ||
"domain": [0, 0.475], | ||
"side": "left", | ||
"ticklabelposition": "inside", | ||
"gridcolor": "white" | ||
}, | ||
"xaxis2": { | ||
"rangemode": "nonnegative", | ||
"anchor": "y2", | ||
"domain": [0.525, 1], | ||
"side": "bottom", | ||
"ticklabelposition": "inside", | ||
"gridcolor": "white" | ||
}, | ||
"yaxis2": { | ||
"anchor": "x2", | ||
"domain": [0, 0.475], | ||
"side": "right", | ||
"ticklabelposition": "inside", | ||
"gridcolor": "white" | ||
}, | ||
"xaxis3": { | ||
"anchor": "y3", | ||
"domain": [0.525, 1], | ||
"side": "top", | ||
"ticklabelposition": "inside", | ||
"gridcolor": "white" | ||
}, | ||
"yaxis3": { | ||
"rangemode": "nonnegative", | ||
"anchor": "x3", | ||
"domain": [0.525, 1], | ||
"side": "right", | ||
"ticklabelposition": "inside", | ||
"gridcolor": "white" | ||
}, | ||
"xaxis4": { | ||
"anchor": "y4", | ||
"domain": [0, 0.475], | ||
"side": "top", | ||
"ticklabelposition": "inside", | ||
"gridcolor": "white" | ||
}, | ||
"yaxis4": { | ||
"rangemode": "nonnegative", | ||
"anchor": "x4", | ||
"domain": [0.525, 1], | ||
"side": "left", | ||
"ticklabelposition": "outside", | ||
"gridcolor": "white" | ||
}, | ||
"font": { | ||
"size": 24 | ||
}, | ||
"plot_bgcolor": "lightblue", | ||
"showlegend": false, | ||
"width": 1000, | ||
"height": 1000, | ||
"margin": { | ||
"t": 40, | ||
"b": 40, | ||
"l": 40, | ||
"r": 40 | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is really the condition we want - we're not trying to completely prevent extra padding for labels when
rangemode
is'nonnegative'
, we just want to prevent the range from going past zero. ie we never want this to prevent the high end of the range from expanding to make room for the labels, nor do we want to prevent the low end from expanding unless it's going to go past zero - so for example if you have for example scatter points from 1 to 10 and there are inside labels on the low end, so that without labels the range would be something like[0.4, 10.6]
, the labels should expand the range down to zero but not beyond.