Skip to content

Commit c4c4c5c

Browse files
committed
handle log
1 parent 03254ab commit c4c4c5c

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

src/plots/cartesian/axes.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,28 @@ function autoShiftMonthBins(binStart, data, dtick, dataMin, calendar) {
543543
// ensure we have minor tick0 and dtick calculated
544544
axes.prepMinorTicks = function(ax) {
545545
var majorDtick = ax._majorDtick;
546-
var dist = majorDtick;
547-
548-
if(ax.type === 'date' && typeof majorDtick === 'string' && majorDtick.charAt(0) === 'M') {
549-
var months = Number(majorDtick.substring(1));
550-
dist = months * ONEAVGMONTH;
551-
}
552-
553546
if(ax.tickmode === 'auto' || !ax.dtick) {
554-
axes.autoTicks(ax, dist / 7, 'minor');
547+
var dist = majorDtick;
548+
549+
if(ax.type === 'date' && typeof majorDtick === 'string' && majorDtick.charAt(0) === 'M') {
550+
var months = Number(majorDtick.substring(1));
551+
dist = months * ONEAVGMONTH / 7;
552+
} else if(ax.type === 'log') {
553+
if(typeof majorDtick === 'string' && majorDtick.charAt(0) === 'L') {
554+
ax.dtick = 'L' + (majorDtick.substring(1) / 2);
555+
return;
556+
} else if(dist === 'D1') {
557+
dist = 1;
558+
} else if(dist === 'D2') {
559+
dist = 'D1';
560+
} else {
561+
dist /= 2;
562+
}
563+
} else {
564+
dist /= 7;
565+
}
566+
567+
axes.autoTicks(ax, dist, 'minor');
555568
}
556569
};
557570

@@ -1294,7 +1307,7 @@ axes.autoTicks = function(ax, roughDTick, isMinor) {
12941307

12951308
if(roughDTick > 0.7) {
12961309
// only show powers of 10
1297-
ax.dtick = Math.ceil(roughDTick);
1310+
ax.dtick = isMinor ? 1 : Math.ceil(roughDTick);
12981311
} else if(Math.abs(rng[1] - rng[0]) < 1) {
12991312
// span is less than one power of 10
13001313
var nt = 1.5 * Math.abs((rng[1] - rng[0]) / roughDTick);
-54.7 KB
Loading
-43.8 KB
Loading
-46.5 KB
Loading

0 commit comments

Comments
 (0)