Skip to content

Commit 74509ef

Browse files
Fix gridcolor for tickmode sync
1 parent 16aa4be commit 74509ef

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

src/plots/cartesian/axes.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,20 +1210,31 @@ axes.calcTicks = function calcTicks(ax, opts) {
12101210
return ticksOut;
12111211
};
12121212

1213+
function filterRangeBreaks(ax, ticksOut){
1214+
if(ax.rangebreaks) {
1215+
// remove ticks falling inside rangebreaks
1216+
ticksOut = ticksOut.filter(function(d) {
1217+
return ax.maskBreaks(d.x) !== BADNUM;
1218+
});
1219+
}
1220+
1221+
return ticksOut;
1222+
}
1223+
12131224
function syncTicks(ax) {
12141225
// get the overlaying axis
12151226
var baseAxis = ax._mainAxis;
12161227

12171228
var ticksOut = [];
1218-
if(baseAxis && baseAxis._vals) {
1229+
if(baseAxis._vals) {
12191230
for(var i = 0; i < baseAxis._vals.length; i++) {
12201231
// get the position of the every tick
12211232
var pos = baseAxis.l2p(baseAxis._vals[i].x);
12221233

12231234
// get the tick for the current axis based on position
12241235
var vali = ax.p2l(pos);
1225-
var val1 = ax.p2l(pos - 0.5);
1226-
var val2 = ax.p2l(pos + 0.5);
1236+
var val1 = ax.p2l(pos - 0.2);
1237+
var val2 = ax.p2l(pos + 0.2);
12271238
var d = 1 + Math.round(Math.log10(Math.abs(val2 - val1)));
12281239
var e = Math.pow(10, -d);
12291240
var valR = Math.round(vali * e) / e;
@@ -1241,12 +1252,8 @@ function syncTicks(ax) {
12411252
}
12421253
}
12431254

1244-
if(ax.rangebreaks) {
1245-
// remove ticks falling inside rangebreaks
1246-
ticksOut = ticksOut.filter(function(d) {
1247-
return ax.maskBreaks(d.x) !== BADNUM;
1248-
});
1249-
}
1255+
ticksOut = filterRangeBreaks(ax, ticksOut);
1256+
12501257
return ticksOut;
12511258
}
12521259

@@ -1296,12 +1303,7 @@ function arrayTicks(ax) {
12961303
}
12971304
}
12981305

1299-
if(ax.rangebreaks) {
1300-
// remove ticks falling inside rangebreaks
1301-
ticksOut = ticksOut.filter(function(d) {
1302-
return ax.maskBreaks(d.x) !== BADNUM;
1303-
});
1304-
}
1306+
ticksOut = filterRangeBreaks(ax, ticksOut);
13051307

13061308
return ticksOut;
13071309
}
@@ -3306,9 +3308,14 @@ axes.drawTicks = function(gd, ax, opts) {
33063308
axes.drawGrid = function(gd, ax, opts) {
33073309
opts = opts || {};
33083310

3311+
if(ax.tickmode === 'sync'){
3312+
// for tickmode sync we use the overlaying axis grid
3313+
return;
3314+
}
3315+
33093316
var cls = ax._id + 'grid';
33103317

3311-
var hasMinor = ax.minor && ax.minor.showgrid && ax.tickmode !== 'sync';
3318+
var hasMinor = ax.minor && ax.minor.showgrid;
33123319
var minorVals = hasMinor ? opts.vals.filter(function(d) { return d.minor; }) : [];
33133320
var majorVals = ax.showgrid ? opts.vals.filter(function(d) { return !d.minor; }) : [];
33143321

0 commit comments

Comments
 (0)