Skip to content

Commit 4f6ab1e

Browse files
committed
hide ticks, dividers, gridlines and zerolines
1 parent 0fe8cec commit 4f6ab1e

10 files changed

+33
-10
lines changed

src/plots/cartesian/axes.js

+33-10
Original file line numberDiff line numberDiff line change
@@ -2804,7 +2804,10 @@ axes.drawTicks = function(gd, ax, opts) {
28042804
.classed('crisp', opts.crisp !== false)
28052805
.call(Color.stroke, ax.tickcolor)
28062806
.style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px')
2807-
.attr('d', opts.path);
2807+
.attr('d', opts.path)
2808+
.style(VISIBLE);
2809+
2810+
hideCounterAxisInsideTickLabels(ax);
28082811

28092812
ticks.attr('transform', opts.transFn);
28102813
};
@@ -3078,8 +3081,10 @@ axes.drawLabels = function(gd, ax, opts) {
30783081
if(bb.bottom > max) hide = true;
30793082
else if(bb.top + (ax.tickangle ? 0 : d.fontSize / 4) < min) hide = true;
30803083
}
3084+
3085+
var t = thisLabel.select('text');
30813086
if(hide) {
3082-
thisLabel.select('text').style(HIDDEN);
3087+
t.style(HIDDEN);
30833088
} else {
30843089
visibleLabelMin = Math.min(visibleLabelMin, isX ? bb.top : bb.left);
30853090
visibleLabelMax = Math.max(visibleLabelMax, isX ? bb.bottom : bb.right);
@@ -3096,14 +3101,32 @@ axes.drawLabels = function(gd, ax, opts) {
30963101

30973102
ax._hideCounterAxisInsideTickLabels = function() {
30983103
if(insideTicklabelposition(ax._anchorAxis || {})) {
3099-
var grid = opts.plotinfo.gridlayer.select('.' + ax._id);
3100-
grid.each(function() {
3101-
d3.select(this).selectAll('path').each(function(d) {
3102-
var q = ax.l2p(d.x) + ax._offset;
3103-
3104-
if(q < ax._visibleLabelMax && q > ax._visibleLabelMin) {
3105-
d3.select(this).style(HIDDEN);
3106-
}
3104+
[
3105+
{ K: 'gridline', L: 'path' },
3106+
{ K: 'zeroline', L: 'path' },
3107+
{ K: 'tick', L: 'path' },
3108+
{ K: 'tick', L: 'text' },
3109+
{ K: 'tick2', L: 'text' },
3110+
{ K: 'tick2', L: 'path' },
3111+
{ K: 'divider', L: 'path' }
3112+
3113+
].forEach(function(e) {
3114+
var isX = ax._id.charAt(0) === 'x';
3115+
3116+
var sel;
3117+
if(e.K === 'gridline') sel = opts.plotinfo.gridlayer;
3118+
else if(e.K === 'zeroline') sel = opts.plotinfo.zerolinelayer;
3119+
else sel = opts.plotinfo[(isX ? 'x' : 'y') + 'axislayer'];
3120+
3121+
sel.each(function() {
3122+
d3.select(this).selectAll(e.L).each(function(d) {
3123+
var q = ax.l2p(d.x) + ax._offset;
3124+
3125+
var t = d3.select(this);
3126+
if(q < ax._visibleLabelMax && q > ax._visibleLabelMin) {
3127+
t.style(HIDDEN);
3128+
}
3129+
});
31073130
});
31083131
});
31093132
}
Loading
-2.14 KB
Loading
-1.02 KB
Loading
-548 Bytes
Loading
-406 Bytes
Loading
-12 KB
Loading
-1 KB
Loading
-3.17 KB
Loading
-1.04 KB
Loading

0 commit comments

Comments
 (0)