Skip to content

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 6 commits into from
Mar 26, 2018
Merged
Changes from 1 commit
Commits
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
12 changes: 6 additions & 6 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,7 @@ axes.doTicks = function(gd, axid, skipTitle) {
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') {
Expand Down Expand Up @@ -1646,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)
Expand All @@ -1661,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();
Expand Down Expand Up @@ -2012,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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice find!

side: ax.side
};
var axLetter = axid.charAt(0);
Expand All @@ -2029,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;
}
Expand Down