Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 660a546

Browse files
committed
fix showdividers:false logic
1 parent 73f0365 commit 660a546

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/plots/cartesian/axes.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ axes.drawOne = function(gd, ax, opts) {
16481648
// The key case here is removing zero lines when the axis bound is zero
16491649
var valsClipped;
16501650

1651-
if(ax.tickson === 'boundaries' && vals.length) {
1651+
if(ax.tickson === 'boundaries') {
16521652
var boundaryVals = getBoundaryVals(ax, vals);
16531653
valsClipped = axes.clipEnds(ax, boundaryVals);
16541654
tickVals = ax.ticks === 'inside' ? valsClipped : boundaryVals;
@@ -1915,10 +1915,12 @@ function getBoundaryVals(ax, vals) {
19151915
}
19161916
};
19171917

1918-
for(i = 0; i < vals.length; i++) {
1919-
_push(vals[i], 0);
1918+
if(vals.length) {
1919+
for(i = 0; i < vals.length; i++) {
1920+
_push(vals[i], 0);
1921+
}
1922+
_push(vals[i - 1], 1);
19201923
}
1921-
_push(vals[i - 1], 1);
19221924

19231925
return out;
19241926
}
@@ -1956,14 +1958,16 @@ function getDividerVals(ax, vals) {
19561958
}
19571959
};
19581960

1959-
for(i = 0; i < vals.length; i++) {
1960-
var d = vals[i];
1961-
if(d.text2 !== current) {
1962-
_push(d, 0);
1961+
if(ax.showdividers && vals.length) {
1962+
for(i = 0; i < vals.length; i++) {
1963+
var d = vals[i];
1964+
if(d.text2 !== current) {
1965+
_push(d, 0);
1966+
}
1967+
current = d.text2;
19631968
}
1964-
current = d.text2;
1969+
_push(vals[i - 1], 1);
19651970
}
1966-
_push(vals[i - 1], 1);
19671971

19681972
return out;
19691973
}
@@ -2507,7 +2511,7 @@ function drawDividers(gd, ax, opts) {
25072511
var vals = opts.vals;
25082512

25092513
var dividers = opts.layer.selectAll('path.' + cls)
2510-
.data(ax.showdividers ? vals : [], makeDataFn(ax));
2514+
.data(vals, makeDataFn(ax));
25112515

25122516
dividers.exit().remove();
25132517

0 commit comments

Comments
 (0)