Skip to content

Commit 8cf99a6

Browse files
committed
stash tickLabels selection in doTicks scope
- so that drawTitle() can reuse it - this can speed up doTicks by 200ms at 50x50 subplots
1 parent 49177a2 commit 8cf99a6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/plots/cartesian/axes.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,7 @@ axes.doTicks = function(gd, axid, skipTitle) {
15641564
var zeroLineWidth = Drawing.crispRound(gd, ax.zerolinewidth, gridWidth);
15651565
var tickWidth = Drawing.crispRound(gd, ax.tickwidth, 1);
15661566
var sides, transfn, tickpathfn, subplots;
1567+
var tickLabels;
15671568
var i;
15681569

15691570
if(ax._counterangle && ax.ticks === 'outside') {
@@ -1646,6 +1647,7 @@ axes.doTicks = function(gd, axid, skipTitle) {
16461647
function drawTicks(container, tickpath) {
16471648
var ticks = container.selectAll('path.' + tcls)
16481649
.data(ax.ticks === 'inside' ? valsClipped : vals, datafn);
1650+
16491651
if(tickpath && ax.ticks) {
16501652
ticks.enter().append('path').classed(tcls, 1).classed('ticks', 1)
16511653
.classed('crisp', 1)
@@ -1661,7 +1663,7 @@ axes.doTicks = function(gd, axid, skipTitle) {
16611663
function drawLabels(container, position) {
16621664
// tick labels - for now just the main labels.
16631665
// TODO: mirror labels, esp for subplots
1664-
var tickLabels = container.selectAll('g.' + tcls).data(vals, datafn);
1666+
tickLabels = container.selectAll('g.' + tcls).data(vals, datafn);
16651667

16661668
if(!isNumeric(position)) {
16671669
tickLabels.remove();
@@ -2012,14 +2014,12 @@ axes.doTicks = function(gd, axid, skipTitle) {
20122014
// now this only applies to regular cartesian axes; colorbars and
20132015
// others ALWAYS call doTicks with skipTitle=true so they can
20142016
// configure their own titles.
2015-
var ax = axisIds.getFromId(gd, axid);
20162017

20172018
// rangeslider takes over a bottom title so drop it here
20182019
if(ax.rangeslider && ax.rangeslider.visible && ax._boundingBox && ax.side === 'bottom') return;
20192020

2020-
var avoidSelection = d3.select(gd).selectAll('g.' + axid + 'tick');
20212021
var avoid = {
2022-
selection: avoidSelection,
2022+
selection: tickLabels,
20232023
side: ax.side
20242024
};
20252025
var axLetter = axid.charAt(0);
@@ -2029,8 +2029,8 @@ axes.doTicks = function(gd, axid, skipTitle) {
20292029

20302030
var transform, counterAxis, x, y;
20312031

2032-
if(avoidSelection.size()) {
2033-
var translation = Drawing.getTranslate(avoidSelection.node().parentNode);
2032+
if(tickLabels.size()) {
2033+
var translation = Drawing.getTranslate(tickLabels.node().parentNode);
20342034
avoid.offsetLeft = translation.x;
20352035
avoid.offsetTop = translation.y;
20362036
}

0 commit comments

Comments
 (0)