-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
More optimization for cartesian subplots #2487
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
928ff6d
do not try to clear ax layers on first render
etpinard a2c5c3d
use ensureSingle in plot bg lsInner routine
etpinard 49177a2
lint in axes.js
etpinard 8cf99a6
stash tickLabels selection in doTicks scope
etpinard 5307125
fixup typo in select query & remove neccessary branch
etpinard 4059764
:hocho: unnecessary scoped var
etpinard 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
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 |
---|---|---|
|
@@ -1539,10 +1539,8 @@ axes.doTicks = function(gd, axid, skipTitle) { | |
return function() { | ||
if(!ax._id) return; | ||
var axDone = axes.doTicks(gd, ax._id); | ||
if(axid === 'redraw') { | ||
ax._r = ax.range.slice(); | ||
ax._rl = Lib.simpleMap(ax._r, ax.r2l); | ||
} | ||
ax._r = ax.range.slice(); | ||
ax._rl = Lib.simpleMap(ax._r, ax.r2l); | ||
return axDone; | ||
}; | ||
})); | ||
|
@@ -1552,21 +1550,22 @@ axes.doTicks = function(gd, axid, skipTitle) { | |
// set scaling to pixels | ||
ax.setScale(); | ||
|
||
var axLetter = axid.charAt(0), | ||
counterLetter = axes.counterLetter(axid), | ||
vals = axes.calcTicks(ax), | ||
datafn = function(d) { return [d.text, d.x, ax.mirror, d.font, d.fontSize, d.fontColor].join('_'); }, | ||
tcls = axid + 'tick', | ||
gcls = axid + 'grid', | ||
zcls = axid + 'zl', | ||
pad = (ax.linewidth || 1) / 2, | ||
labelStandoff = (ax.ticks === 'outside' ? ax.ticklen : 0), | ||
labelShift = 0, | ||
gridWidth = Drawing.crispRound(gd, ax.gridwidth, 1), | ||
zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth), | ||
tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1), | ||
sides, transfn, tickpathfn, subplots, | ||
i; | ||
var axLetter = axid.charAt(0); | ||
var counterLetter = axes.counterLetter(axid); | ||
var vals = axes.calcTicks(ax); | ||
var datafn = function(d) { return [d.text, d.x, ax.mirror, d.font, d.fontSize, d.fontColor].join('_'); }; | ||
var tcls = axid + 'tick'; | ||
var gcls = axid + 'grid'; | ||
var zcls = axid + 'zl'; | ||
var pad = (ax.linewidth || 1) / 2; | ||
var labelStandoff = (ax.ticks === 'outside' ? ax.ticklen : 0); | ||
var labelShift = 0; | ||
var gridWidth = Drawing.crispRound(gd, ax.gridwidth, 1); | ||
var zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth); | ||
var tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1); | ||
var sides, transfn, tickpathfn, subplots; | ||
var tickLabels; | ||
var i; | ||
|
||
if(ax._counterangle && ax.ticks === 'outside') { | ||
var caRad = ax._counterangle * Math.PI / 180; | ||
|
@@ -1616,10 +1615,11 @@ axes.doTicks = function(gd, axid, skipTitle) { | |
Lib.warn('Unrecognized doTicks axis:', axid); | ||
return; | ||
} | ||
var axside = ax.side || sides[0], | ||
|
||
var axside = ax.side || sides[0]; | ||
// which direction do the side[0], side[1], and free ticks go? | ||
// then we flip if outside XOR y axis | ||
ticksign = [-1, 1, axside === sides[1] ? 1 : -1]; | ||
var ticksign = [-1, 1, axside === sides[1] ? 1 : -1]; | ||
if((ax.ticks !== 'inside') === (axLetter === 'x')) { | ||
ticksign = ticksign.map(function(v) { return -v; }); | ||
} | ||
|
@@ -1647,6 +1647,7 @@ axes.doTicks = function(gd, axid, skipTitle) { | |
function drawTicks(container, tickpath) { | ||
var ticks = container.selectAll('path.' + tcls) | ||
.data(ax.ticks === 'inside' ? valsClipped : vals, datafn); | ||
|
||
if(tickpath && ax.ticks) { | ||
ticks.enter().append('path').classed(tcls, 1).classed('ticks', 1) | ||
.classed('crisp', 1) | ||
|
@@ -1662,7 +1663,7 @@ axes.doTicks = function(gd, axid, skipTitle) { | |
function drawLabels(container, position) { | ||
// tick labels - for now just the main labels. | ||
// TODO: mirror labels, esp for subplots | ||
var tickLabels = container.selectAll('g.' + tcls).data(vals, datafn); | ||
tickLabels = container.selectAll('g.' + tcls).data(vals, datafn); | ||
|
||
if(!isNumeric(position)) { | ||
tickLabels.remove(); | ||
|
@@ -2013,14 +2014,12 @@ axes.doTicks = function(gd, axid, skipTitle) { | |
// now this only applies to regular cartesian axes; colorbars and | ||
// others ALWAYS call doTicks with skipTitle=true so they can | ||
// configure their own titles. | ||
var ax = axisIds.getFromId(gd, axid); | ||
|
||
// rangeslider takes over a bottom title so drop it here | ||
if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return; | ||
|
||
var avoidSelection = d3.select(gd).selectAll('g.' + axid + 'tick'); | ||
var avoid = { | ||
selection: avoidSelection, | ||
selection: tickLabels, | ||
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. nice find! |
||
side: ax.side | ||
}; | ||
var axLetter = axid.charAt(0); | ||
|
@@ -2030,8 +2029,8 @@ axes.doTicks = function(gd, axid, skipTitle) { | |
|
||
var transform, counterAxis, x, y; | ||
|
||
if(avoidSelection.size()) { | ||
var translation = Drawing.getTranslate(avoidSelection.node().parentNode); | ||
if(tickLabels.size()) { | ||
var translation = Drawing.getTranslate(tickLabels.node().parentNode); | ||
avoid.offsetLeft = translation.x; | ||
avoid.offsetTop = translation.y; | ||
} | ||
|
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.
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.
OK... this is the only caller using
doTicks(gd, '')
right? From the logic below it looks like there may have been one previously (or someone just callingdoTicks(gd)
) but I don't see it now. I'm a little reticent to add new branches insidedoTicks
when what we really need to do is unpack it into more digestible pieces - but that's probably a project for another time refactoring all ofaxes.js
.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.
That's correct.