Skip to content

Commit 5d5c8da

Browse files
Improved tickmode sync logic to round ticks
1 parent 8c25bf6 commit 5d5c8da

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/plots/cartesian/axes.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,8 +1222,14 @@ function syncTicks(ax) {
12221222

12231223
// get the tick for the current axis based on position
12241224
var vali = ax.p2l(pos);
1225-
1225+
var val1 = ax.p2l(pos - 0.5);
1226+
var val2 = ax.p2l(pos + 0.5);
1227+
var d = 1 + Math.round(Math.log10(Math.abs(val2 - val1)));
1228+
var e = Math.pow(10, -d);
1229+
var valR = Math.round(vali * e) / e;
1230+
var objR = axes.tickText(ax, valR);
12261231
var obj = axes.tickText(ax, vali);
1232+
obj.text = objR.text;
12271233

12281234
// assign minor ticks
12291235
if(baseAxis._vals[i].minor) {

0 commit comments

Comments
 (0)