@@ -1210,20 +1210,31 @@ axes.calcTicks = function calcTicks(ax, opts) {
1210
1210
return ticksOut ;
1211
1211
} ;
1212
1212
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
+
1213
1224
function syncTicks ( ax ) {
1214
1225
// get the overlaying axis
1215
1226
var baseAxis = ax . _mainAxis ;
1216
1227
1217
1228
var ticksOut = [ ] ;
1218
- if ( baseAxis && baseAxis . _vals ) {
1229
+ if ( baseAxis . _vals ) {
1219
1230
for ( var i = 0 ; i < baseAxis . _vals . length ; i ++ ) {
1220
1231
// get the position of the every tick
1221
1232
var pos = baseAxis . l2p ( baseAxis . _vals [ i ] . x ) ;
1222
1233
1223
1234
// get the tick for the current axis based on position
1224
1235
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 ) ;
1227
1238
var d = 1 + Math . round ( Math . log10 ( Math . abs ( val2 - val1 ) ) ) ;
1228
1239
var e = Math . pow ( 10 , - d ) ;
1229
1240
var valR = Math . round ( vali * e ) / e ;
@@ -1241,12 +1252,8 @@ function syncTicks(ax) {
1241
1252
}
1242
1253
}
1243
1254
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
+
1250
1257
return ticksOut ;
1251
1258
}
1252
1259
@@ -1296,12 +1303,7 @@ function arrayTicks(ax) {
1296
1303
}
1297
1304
}
1298
1305
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 ) ;
1305
1307
1306
1308
return ticksOut ;
1307
1309
}
@@ -3306,9 +3308,14 @@ axes.drawTicks = function(gd, ax, opts) {
3306
3308
axes . drawGrid = function ( gd , ax , opts ) {
3307
3309
opts = opts || { } ;
3308
3310
3311
+ if ( ax . tickmode === 'sync' ) {
3312
+ // for tickmode sync we use the overlaying axis grid
3313
+ return ;
3314
+ }
3315
+
3309
3316
var cls = ax . _id + 'grid' ;
3310
3317
3311
- var hasMinor = ax . minor && ax . minor . showgrid && ax . tickmode !== 'sync' ;
3318
+ var hasMinor = ax . minor && ax . minor . showgrid ;
3312
3319
var minorVals = hasMinor ? opts . vals . filter ( function ( d ) { return d . minor ; } ) : [ ] ;
3313
3320
var majorVals = ax . showgrid ? opts . vals . filter ( function ( d ) { return ! d . minor ; } ) : [ ] ;
3314
3321
0 commit comments