Skip to content

Mult axis formatting #6334

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

Merged
merged 63 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
e4a81e3
Add shift parameter and set defaults accordingly
hannahker Sep 29, 2022
de79261
Set defaults
hannahker Sep 29, 2022
18f21cb
Simplify logic
hannahker Oct 3, 2022
0e85776
Fix coercion logic
hannahker Oct 3, 2022
ba0c587
Include shift logic during drawing
hannahker Oct 4, 2022
2731eb8
Add baseline image and fix syntax for tests
hannahker Oct 4, 2022
c535c56
Fixes for tests
hannahker Oct 4, 2022
a8fcadc
Update plot schema
hannahker Oct 5, 2022
0f93feb
Fix syntax
hannahker Oct 5, 2022
d79ef96
pass axShifts in opts & bypass undefined axShifts
archmoj Oct 5, 2022
b1d10c5
Shift axis line if applicable
hannahker Oct 5, 2022
3fa0f0c
Add new mocks and set default position according to overlaying domain
hannahker Oct 6, 2022
50fe1fd
Shift axes according to overlaying group
hannahker Oct 6, 2022
1984b7e
Clean up code to increment shifts
hannahker Oct 6, 2022
b9c77b8
Set shift valType to any
hannahker Oct 13, 2022
8a420d6
Add jasmine tests for defaults and update baselines
hannahker Oct 13, 2022
8d0c9eb
Fix syntax
hannahker Oct 13, 2022
5528a35
Enable numeric shift values
hannahker Oct 14, 2022
fbdc5a4
Fix zerolines bug
hannahker Oct 14, 2022
d742cc5
Fix logic in shift values
hannahker Oct 14, 2022
c2ba6b0
Push axis to layout in jasmine test and add baseline
hannahker Oct 14, 2022
cb66b12
Fix syntax
hannahker Oct 14, 2022
38f17b2
Add more jasmine tests for defaults relative to shift
hannahker Oct 14, 2022
bbf682f
Fix bugs with scroll and drag interactions
hannahker Oct 21, 2022
0175979
Simplify syntax
hannahker Oct 21, 2022
7a1c9d8
Adjust mock to have variable axis sizes
hannahker Oct 24, 2022
5aee58b
Set axis shift after drawing
hannahker Oct 27, 2022
fd098a9
Push out axes by estimated depth
hannahker Nov 2, 2022
79c2c74
Move axis line drawing to axes file
hannahker Nov 4, 2022
bc9bfa2
Avoid drawing lines when not necessary
hannahker Nov 4, 2022
5ffbdd2
Calculate depth without axis titles
hannahker Nov 8, 2022
168b3db
Remove arrow functions
hannahker Nov 10, 2022
472efb9
Fix failing dragbox test and mock validation
hannahker Nov 10, 2022
0c33429
Add hard coded padding and titles to axes
hannahker Nov 10, 2022
83e7f82
Remove whitespace
hannahker Nov 10, 2022
6e71f53
Replace mocks
hannahker Nov 10, 2022
28eadb0
Merge pull request #6357 from plotly/mult-axis-formatting-depth
hannahker Nov 17, 2022
6d5ecb5
Revert changes to axis line drawing
hannahker Dec 5, 2022
2b951fd
Merge branch 'master' into mult-axis-formatting
hannahker Dec 5, 2022
f97f27c
Properly account for axis title positioning
hannahker Dec 9, 2022
de4dd05
Fix syntax and add updated mocks
hannahker Dec 9, 2022
38d3e71
Make sure that the axes redraw with dragbox still works
hannahker Dec 9, 2022
683d0f3
Account for case where title fits inside axis labels
hannahker Dec 9, 2022
eca5d4f
Simplify syntax with feedback
hannahker Dec 14, 2022
b84f89d
Update baselines with smaller padding
hannahker Dec 15, 2022
5f2240f
Add jasmine test for axis positioning
hannahker Dec 15, 2022
81b661f
Fix syntax
hannahker Dec 15, 2022
ec1f855
Simplify function call
hannahker Dec 16, 2022
e56020d
Redraw if needed based on shift param
hannahker Dec 19, 2022
b8bfab5
Add baseline for new mock and fix syntax
hannahker Dec 19, 2022
b41678c
Merge branch 'master' into mult-axis-formatting
hannahker Dec 20, 2022
6064e5a
Rename redraw function and remove export
hannahker Dec 20, 2022
085c2b7
Adjust API to have both autoshift and shift params
hannahker Dec 21, 2022
49ddf46
Update plot schema and baseline
hannahker Dec 21, 2022
a45eca6
Adjust logic for default setting
hannahker Dec 21, 2022
56605bc
Adjust text for docs
hannahker Dec 21, 2022
5506ed4
Improve documentation and simplify syntax
hannahker Dec 21, 2022
61c2889
set ax._fullDepth only when needed
archmoj Dec 21, 2022
d06bc6d
simplify autoshift checks
archmoj Dec 21, 2022
bab8020
adjust description keys and values
archmoj Dec 21, 2022
09b5d0c
no shift when zero
archmoj Dec 21, 2022
b89f59a
do not add autoshift and shift to xaxis for now
archmoj Dec 21, 2022
948809b
adjust asterisks for new attributes shift & autoshift
archmoj Dec 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,21 @@ plots.autoMargin = function(gd, id, o) {
}
};

plots.redrawWithShift = function(gd) {
if('_redrawFromAutoMarginCount' in gd._fullLayout) {
return false
}
var axList = axisIDs.list(gd, '', true)
var isShift = false;
for(var ax in axList) {
if(isShift === true){
return isShift;
}
isShift = axList[ax].shift
}
return isShift
}

plots.doAutoMargin = function(gd) {
var fullLayout = gd._fullLayout;
var width = fullLayout.width;
Expand Down Expand Up @@ -2073,7 +2088,7 @@ plots.doAutoMargin = function(gd) {
gs.h = Math.round(height) - gs.t - gs.b;

// if things changed and we're not already redrawing, trigger a redraw
if(!fullLayout._replotting && plots.didMarginChange(oldMargins, gs)) {
if(!fullLayout._replotting && (plots.didMarginChange(oldMargins, gs) || plots.redrawWithShift(gd))) {
if('_redrawFromAutoMarginCount' in fullLayout) {
fullLayout._redrawFromAutoMarginCount++;
} else {
Expand Down
96 changes: 96 additions & 0 deletions test/image/mocks/zz-mult-yaxes-redraw.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"data": [
{
"x": [
1,
2,
3
],
"y": [
4,
5,
6
],
"name": "yaxis1 data",
"type": "scatter"
},
{
"x": [
2,
3,
4
],
"y": [
4,
5,
6
],
"name": "yaxis2 data",
"yaxis": "y2",
"type": "scatter"
},
{
"x": [
3,
4,
5
],
"y": [
4,
5,
6
],
"name": "yaxis3 data",
"yaxis": "y3",
"type": "scatter"
},
{
"x": [
4,
5,
6
],
"y": [
1,
2,
3
],
"name": "yaxis4 data",
"yaxis": "y4",
"type": "scatter"
}
],
"layout": {
"title": {
"text": "multiple y-axes example"
},
"xaxis": {"domain": [0.25, 0.75]},
"width": 800,
"yaxis": {
"showline": true,
"title": {"text": "axis 1"}
},
"yaxis2": {
"overlaying": "y",
"showline": true,
"side": "right",
"title": {"text": "axis 2"}
},
"yaxis3": {
"anchor": "free",
"overlaying": "y",
"showline": true,
"shift": true,
"side": "right",
"title": {"text": "axis 3"}
},
"yaxis4": {
"anchor": "free",
"overlaying": "y",
"showline": true,
"shift": true,
"side": "left",
"title": {"text": "axis 4"}
}
}
}