Skip to content

Commit ec15832

Browse files
committed
hide zerolines overlapping inside ticklabels
1 parent 769c7b8 commit ec15832

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/plots/cartesian/axes.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var BADNUM = constants.BADNUM;
3737
var VISIBLE = { visibility: 'visible' };
3838
var HIDDEN = { visibility: 'hidden' };
3939

40+
var ZERO_PATH = { K: 'zeroline' };
4041
var GRID_PATH = { K: 'gridline', L: 'path' };
4142
var TICK_PATH = { K: 'tick', L: 'path' };
4243
var TICK_TEXT = { K: 'tick', L: 'text' };
@@ -2921,7 +2922,10 @@ axes.drawZeroLine = function(gd, ax, opts) {
29212922
zl.attr('transform', opts.transFn)
29222923
.attr('d', opts.path)
29232924
.call(Color.stroke, ax.zerolinecolor || Color.defaultLine)
2924-
.style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px');
2925+
.style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px')
2926+
.style(VISIBLE);
2927+
2928+
hideCounterAxisInsideTickLabels(ax, [ZERO_PATH]);
29252929
};
29262930

29272931
/**
@@ -3101,6 +3105,7 @@ axes.drawLabels = function(gd, ax, opts) {
31013105
ax._hideCounterAxisInsideTickLabels = function(partialOpts) {
31023106
if(insideTicklabelposition(ax._anchorAxis || {})) {
31033107
(partialOpts || [
3108+
ZERO_PATH,
31043109
GRID_PATH,
31053110
TICK_PATH,
31063111
TICK_TEXT
@@ -3109,12 +3114,15 @@ axes.drawLabels = function(gd, ax, opts) {
31093114
if(isTickText && ax.ticklabelmode === 'period') return;
31103115

31113116
var sel;
3112-
if(e.K === 'gridline') sel = opts.plotinfo.gridlayer.selectAll('.' + ax._id);
3117+
if(e.K === ZERO_PATH.K) sel = opts.plotinfo.zerolinelayer.selectAll('.' + ax._id + 'zl');
3118+
else if(e.K === GRID_PATH.K) sel = opts.plotinfo.gridlayer.selectAll('.' + ax._id);
31133119
else sel = opts.plotinfo[ax._id.charAt(0) + 'axislayer'];
31143120

3115-
31163121
sel.each(function() {
3117-
d3.select(this).selectAll(e.L).each(function(d) {
3122+
var w = d3.select(this);
3123+
if(e.L) w = w.selectAll(e.L);
3124+
3125+
w.each(function(d) {
31183126
var q = ax.l2p(d.x) + ax._offset;
31193127

31203128
var t = d3.select(this);
Loading

0 commit comments

Comments
 (0)