10000 Adding automargin support to plot titles by hannahker · Pull Request #6428 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Adding automargin support to plot titles #6428

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
Mar 15, 2023
Merged
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
04f8825
Add more tests for yref=container
hannahker Feb 28, 2023
ad202d9
Ajust default setting
hannahker Feb 28, 2023
9611672
Remove outdated mock
hannahker Mar 1, 2023
c4d1076
Update mock baselines
hannahker Mar 1, 2023
21a9e59
Fix syntax
hannahker Mar 1, 2023
78cecff
Remove f from test
hannahker Mar 1, 2023
fd111d5
Set yanchor properly when title is at bottom
hannahker Mar 6, 2023
2a47c00
Make defaults setting logic more readable
hannahker Mar 7, 2023
52b37c0
Add reservedMargins logic
hannahker Mar 7, 2023
4322c7b
Revert some changes to test
hannahker Mar 7, 2023
73ccaf4
Fix bugs
hannahker Mar 8, 2023
a3462d2
Fix more bugs from redraw
hannahker Mar 8, 2023
33bbbef
Apply review comments
hannahker Mar 9, 2023
9af5cbd
Add jasmine test for interaction with x axis
hannahker Mar 9, 2023
67cf8da
Push pie test fix
hannahker Mar 9, 2023
16c0bcf
Fix scooting behaviour to account for reserved margin space
hannahker Mar 9, 2023
17c3244
Check if automargin is necessary before applying
hannahker Mar 10, 2023
c014702
Update tests
hannahker Mar 10, 2023
e59b18f
Warn when title.y is being set to 1
hannahker Mar 10, 2023
ddaf013
Fix syntax and another mock update
hannahker Mar 10, 2023
de7ca48
Apply review comments
hannahker Mar 10, 2023
e77126c
Calc bb for title
hannahker Mar 10, 2023
26ca553
Fix warning log
hannahker Mar 10, 2023
e5e8a2a
Update parameter description
hannahker Mar 10, 2023
d70fb46
Reposition properly
hannahker Mar 10, 2023
616057f
Merge branch 'master' into automargin-title
hannahker Mar 10, 2023
3523406
Only reposition title if necessary
hannahker Mar 10, 2023
90bd374
Fix syntax
hannahker Mar 10, 2023
158791f
Fix tests
hannahker Mar 10, 2023
c4e706e
Merge branch 'automargin-title-dev' into automargin-title
hannahker Mar 10, 2023
087c162
Adjust tests to match rendering in CI
hannahker Mar 13, 2023
c4d75d4
Update mocks
hannahker Mar 13, 2023
a257836
Add review comment
hannahker Mar 13, 2023
662628e
Update mock baselines
hannahker Mar 13, 2023
e4b5f29
Adjust titles on mocks
hannahker Mar 13, 2023
3dcaab8
Update baselines
hannahker Mar 13, 2023
2a0011a
Add milti-line title
hannahker Mar 14, 2023
a8185f4
Update baselines
hannahker Mar 14, 2023
0c0e47e
Revert dy change
hannahker Mar 14, 2023
7f89c73
move smart default for title.y and title.yanchor to supply defaults
archmoj Mar 10, 2023
132c57b
Adjust dy to fix offset
hannahker Mar 15, 2023
7d4e352
baseline update
archmoj Mar 15, 2023
ad7c6f0
Add draftlog
hannahker Mar 15, 2023
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
Prev Previous commit
Next Next commit
Only reposition title if necessary
  • Loading branch information
hannahker committed Mar 10, 2023
commit 352340660a5fa2ee73b57a760baf260e04d173f4
25 changes: 17 additions & 8 deletions src/plot_api/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,18 @@ exports.drawMainTitle = function(gd) {
propContainer: fullLayout,
propName: 'title.text',
placeholder: fullLayout._dfltTitle.plot,
attributes: ({
x: x,
y: y,
'text-anchor': textAnchor,
dy: dy
})
});

var titleObj = d3.selectAll('.gtitle');


if(title.text && title.automargin) {
var titleObj = d3.selectAll('.gtitle');
var titleHeight = Drawing.bBox(titleObj.node()).height;
var pushMargin = needsMarginPush(gd, title, titleHeight);
if(pushMargin > 0) {
Expand All @@ -424,16 +431,18 @@ exports.drawMainTitle = function(gd) {
dy = getMainTitleDy(fullLayout);
y = getMainTitleY(fullLayout, dy);
applyTitleAutoMargin(gd, y, pushMargin, titleHeight);

// Position the title once we know where it needs to be
titleObj.attr({
x: x,
y: y,
'text-anchor': textAnchor,
dy: dy
}).call(svgTextUtils.positionText, x, y);
}
}

// Position the title once we know where it needs to be
titleObj.attr({
x: x,
y: y,
'text-anchor': textAnchor,
dy: dy
}).call(svgTextUtils.positionText, x, y);

};


Expand Down
0