-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
WIP: Multiple y-axis formatting #6320
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f013426
Add mock and exploratory code
hannahker 7e45c3b
MVP with hard coded title offset
hannahker 68b8f8f
Add more complex mock and clean up code
hannahker 4194097
Axis titles are working
hannahker 23efbe8
Tick labels position with automargin
hannahker 736db9d
Fix formatting
hannahker e5f5e4c
Calculate mainlineposition when drawing axis
hannahker 06d1daf
Simplify syntax
hannahker 78c51ca
Improve logic
hannahker 4194f8f
To check image tests
hannahker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2318,7 +2318,6 @@ axes.drawOne = function(gd, ax, opts, allDepths) { | |
if(!mainPlotinfo) return; | ||
|
||
var mainAxLayer = mainPlotinfo[axLetter + 'axislayer']; | ||
var mainLinePosition = ax._mainLinePosition; | ||
var mainMirrorPosition = ax._mainMirrorPosition; | ||
|
||
var vals = ax._vals = axes.calcTicks(ax); | ||
|
@@ -2345,12 +2344,20 @@ axes.drawOne = function(gd, ax, opts, allDepths) { | |
// to determine how much to shift this one out by | ||
// TODO: Also need to account for the expected depth of the current axis | ||
// (if drawing from the left inwards) | ||
if(axLetter === 'y') { | ||
if(axLetter === 'y' & !ax.position > 0) { | ||
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. I am not sure if understand the statement here. |
||
ax._xshift = allDepths[ax.side]; | ||
} else { | ||
ax._xshift = null; | ||
ax._xshift = 0; | ||
} | ||
|
||
var mainLinePosition; | ||
if (ax._xshift > 0){ | ||
// Calculate main line position from function | ||
mainLinePosition = getLinePosition(ax, ax._anchorAxis, ax.side) | ||
} else { | ||
mainLinePosition = ax._mainLinePosition; | ||
} | ||
|
||
// calcLabelLevelBbox can be expensive, | ||
// so make sure to not call it twice during the same Axes.drawOne call | ||
// by stashing label-level bounding boxes per tick-label class | ||
|
@@ -4240,3 +4247,21 @@ function hideCounterAxisInsideTickLabels(ax, opts) { | |
} | ||
} | ||
} | ||
|
||
// Copied over from subroutines.js since I want to calculate the line position when | ||
// drawing each y-axis if there is an xshift to be applied | ||
// TODO: Possible to reference this from subroutines.js directly or put the function in some general utils file? | ||
function getLinePosition(ax, counterAx, side) { | ||
var lwHalf = ax._lw / 2; | ||
var xshift = ax.position > 0 ? 0 : ax._xshift; | ||
xshift = (xshift == undefined) ? 0 : xshift; | ||
|
||
if(ax._id.charAt(0) === 'x') { | ||
if(!counterAx) return gs.t + gs.h * (1 - (ax.position || 0)) + (lwHalf % 1); | ||
else if(side === 'top') return counterAx._offset - lwHalf; | ||
return counterAx._offset + counterAx._length + lwHalf; | ||
} | ||
if(!counterAx) return gs.l + gs.w * (ax.position || 0) + (lwHalf % 1) + xshift; | ||
else if(side === 'right') return counterAx._offset + counterAx._length + lwHalf + xshift; | ||
return counterAx._offset - lwHalf - xshift; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.