Skip to content

Commit

Permalink
interactively hide tick labels
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Apr 6, 2021
1 parent caf3239 commit e683b07
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,10 @@ axes.drawLabels = function(gd, ax, opts) {
// sync label: just position it now.
positionLabels(thisLabel, tickAngle);
}
});
})
.style('display', null); // visible

hideCounterAxisInsideTickLabels(ax, [TICK_TEXT]);

tickLabels.exit().remove();

Expand Down Expand Up @@ -3040,7 +3043,7 @@ axes.drawLabels = function(gd, ax, opts) {
});

if(isInside) {
thisText.style('display', null); // visible
thisText.style('opacity', 0); // visible

if(ax._hideOutOfRangeInsideTickLabels) {
ax._hideOutOfRangeInsideTickLabels();
Expand Down Expand Up @@ -3088,8 +3091,10 @@ axes.drawLabels = function(gd, ax, opts) {

var t = thisLabel.select('text');
if(hide) {
t.style('display', 'none'); // hidden
t.style('opacity', 0); // hidden
} else {
t.style('opacity', 1); // visible

if(side === 'bottom' || side === 'right') {
visibleLabelMin = Math.min(visibleLabelMin, isX ? bb.top : bb.left);
} else {
Expand Down Expand Up @@ -3138,7 +3143,7 @@ axes.drawLabels = function(gd, ax, opts) {
var t = d3.select(this);
if(q < ax._visibleLabelMax && q > ax._visibleLabelMin) {
t.style('display', 'none'); // hidden
} else if(e.K === 'tick' && e.L === 'path') {
} else if(e.K === 'tick') {
t.style('display', null); // visible
}
});
Expand Down
Binary file modified test/image/baselines/ticklabelposition-a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/ticklabelposition-b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/ticklabelposition-c.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e683b07

Please sign in to comment.