Skip to content

Commit 37a0840

Browse files
committed
use tickfromat getter and add question comment
1 parent ea6eca1 commit 37a0840

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/plots/cartesian/axes.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,10 @@ axes.calcTicks = function calcTicks(ax, opts) {
702702
var maxRange = Math.max(rng[0], rng[1]);
703703

704704
var definedDelta;
705-
if(isPeriod && ax.tickformat) {
705+
var tickformat = axes.getTickFormat(ax); // don't use ax.tickformat directly
706+
if(isPeriod) {
706707
if(
707-
!(/%[fLQsSMHIpX]/.test(ax.tickformat))
708+
!(/%[fLQsSMHIpX]/.test(tickformat))
708709
// %f: microseconds as a decimal number [000000, 999999]
709710
// %L: milliseconds as a decimal number [000, 999]
710711
// %Q: milliseconds since UNIX epoch
@@ -717,7 +718,7 @@ axes.calcTicks = function calcTicks(ax, opts) {
717718
// %X: the locale’s time, such as %-I:%M:%S %p
718719
) {
719720
if(
720-
/%[Aadejuwx]/.test(ax.tickformat)
721+
/%[Aadejuwx]/.test(tickformat)
721722
// %A: full weekday name
722723
// %a: abbreviated weekday name
723724
// %d: zero-padded day of the month as a decimal number [01,31]
@@ -728,23 +729,23 @@ axes.calcTicks = function calcTicks(ax, opts) {
728729
// %x: the locale’s date, such as %-m/%-d/%Y
729730
) definedDelta = ONEDAY;
730731
else if(
731-
/%[UVW]/.test(ax.tickformat)
732+
/%[UVW]/.test(tickformat)
732733
// %U: Sunday-based week of the year as a decimal number [00,53]
733734
// %V: ISO 8601 week of the year as a decimal number [01, 53]
734735
// %W: Monday-based week of the year as a decimal number [00,53]
735736
) definedDelta = ONEWEEK;
736737
else if(
737-
/%[Bbm]/.test(ax.tickformat)
738+
/%[Bbm]/.test(tickformat)
738739
// %B: full month name
739740
// %b: abbreviated month name
740741
// %m: month as a decimal number [01,12]
741742
) definedDelta = ONEAVGMONTH;
742743
else if(
743-
/%[q]/.test(ax.tickformat)
744+
/%[q]/.test(tickformat)
744745
// %q: quarter of the year as a decimal number [1,4]
745746
) definedDelta = ONEAVGQUARTER;
746747
else if(
747-
/%[Yy]/.test(ax.tickformat)
748+
/%[Yy]/.test(tickformat)
748749
// %Y: year with century as a decimal number, such as 1999
749750
// %y: year without century as a decimal number [00,99]
750751
) definedDelta = ONEAVGYEAR;
@@ -945,7 +946,7 @@ axes.autoTicks = function(ax, roughDTick) {
945946
// 2 or 3 days... but that's a weird enough case that we'll ignore it.
946947
ax.tick0 = Lib.dateTick0(ax.calendar, true);
947948

948-
if(/%[uVW]/.test(ax.tickformat)) {
949+
if(/%[uVW]/.test(ax.tickformat)) { // should we use axes.getTickFormat(ax) instead here?
949950
// replace Sunday with Monday for ISO and Monday-based formats
950951
var len = ax.tick0.length;
951952
var lastD = +ax.tick0[len - 1];

0 commit comments

Comments
 (0)