Skip to content

Commit a7fc3c3

Browse files
committed
add partial hide options
1 parent c76214c commit a7fc3c3

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/plots/cartesian/axes.js

+18-16
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ var BADNUM = constants.BADNUM;
3737
var VISIBLE = { visibility: 'visible' };
3838
var HIDDEN = { visibility: 'hidden' };
3939

40+
var GRID_PATH = { K: 'gridline', L: 'path' };
41+
var ZERO_PATH = { K: 'zeroline', L: 'path' };
42+
var TICK_PATH = { K: 'tick', L: 'path' };
43+
var TICK_TEXT = { K: 'tick', L: 'text' };
44+
4045
var alignmentConstants = require('../../constants/alignment');
4146
var MID_SHIFT = alignmentConstants.MID_SHIFT;
4247
var CAP_SHIFT = alignmentConstants.CAP_SHIFT;
@@ -2807,7 +2812,7 @@ axes.drawTicks = function(gd, ax, opts) {
28072812
.attr('d', opts.path)
28082813
.style(VISIBLE);
28092814

2810-
hideCounterAxisInsideTickLabels(ax);
2815+
hideCounterAxisInsideTickLabels(ax, [TICK_PATH]);
28112816

28122817
ticks.attr('transform', opts.transFn);
28132818
};
@@ -2873,7 +2878,7 @@ axes.drawGrid = function(gd, ax, opts) {
28732878
.style('stroke-width', ax._gw + 'px')
28742879
.style(VISIBLE);
28752880

2876-
hideCounterAxisInsideTickLabels(ax);
2881+
hideCounterAxisInsideTickLabels(ax, [GRID_PATH]);
28772882

28782883
if(typeof opts.path === 'function') grid.attr('d', opts.path);
28792884
};
@@ -2925,7 +2930,7 @@ axes.drawZeroLine = function(gd, ax, opts) {
29252930
.style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px')
29262931
.style(VISIBLE);
29272932

2928-
hideCounterAxisInsideTickLabels(ax);
2933+
hideCounterAxisInsideTickLabels(ax, [ZERO_PATH]);
29292934
};
29302935

29312936
/**
@@ -3102,21 +3107,18 @@ axes.drawLabels = function(gd, ax, opts) {
31023107
}
31033108
};
31043109

3105-
ax._hideCounterAxisInsideTickLabels = function() {
3110+
ax._hideCounterAxisInsideTickLabels = function(partialOpts) {
31063111
if(insideTicklabelposition(ax._anchorAxis || {})) {
3107-
[
3108-
{ K: 'gridline', L: 'path' },
3109-
{ K: 'zeroline', L: 'path' },
3110-
{ K: 'tick', L: 'path' },
3111-
{ K: 'tick', L: 'text' }
3112-
3113-
].forEach(function(e) {
3114-
var isX = ax._id.charAt(0) === 'x';
3115-
3112+
(partialOpts || [
3113+
GRID_PATH,
3114+
ZERO_PATH,
3115+
TICK_PATH,
3116+
TICK_TEXT
3117+
]).forEach(function(e) {
31163118
var sel;
31173119
if(e.K === 'gridline') sel = opts.plotinfo.gridlayer;
31183120
else if(e.K === 'zeroline') sel = opts.plotinfo.zerolinelayer;
3119-
else sel = opts.plotinfo[(isX ? 'x' : 'y') + 'axislayer'];
3121+
else sel = opts.plotinfo[ax._id.charAt(0) + 'axislayer'];
31203122

31213123
sel.each(function() {
31223124
d3.select(this).selectAll(e.L).each(function(d) {
@@ -3771,10 +3773,10 @@ function insideTicklabelposition(ax) {
37713773
return ((ax.ticklabelposition || '').indexOf('inside') !== -1);
37723774
}
37733775

3774-
function hideCounterAxisInsideTickLabels(ax) {
3776+
function hideCounterAxisInsideTickLabels(ax, opts) {
37753777
if(insideTicklabelposition(ax._anchorAxis || {})) {
37763778
if(ax._hideCounterAxisInsideTickLabels) {
3777-
ax._hideCounterAxisInsideTickLabels();
3779+
ax._hideCounterAxisInsideTickLabels(opts);
37783780
}
37793781
}
37803782
}

0 commit comments

Comments
 (0)