Skip to content

Commit 59eadc3

Browse files
committed
don't try to re-align timeAxisSplits for incrs <= 1hr. close #293.
1 parent da99f21 commit 59eadc3

5 files changed

Lines changed: 73 additions & 57 deletions

File tree

dist/uPlot.cjs.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -669,27 +669,31 @@ function timeAxisSplits(tzDate) {
669669
while (1) {
670670
split$1 = round3(split$1 + foundIncr);
671671

672-
var expectedHour = floor(round6(prevHour + incrHours)) % 24;
673-
var splitDate$1 = tzDate(split$1);
674-
var actualHour = splitDate$1.getHours();
672+
if (split$1 > scaleMax)
673+
{ break; }
675674

676-
var dstShift = actualHour - expectedHour;
675+
if (incrHours > 1) {
676+
var expectedHour = floor(round6(prevHour + incrHours)) % 24;
677+
var splitDate$1 = tzDate(split$1);
678+
var actualHour = splitDate$1.getHours();
677679

678-
if (dstShift > 1)
679-
{ dstShift = -1; }
680+
var dstShift = actualHour - expectedHour;
680681

681-
split$1 -= dstShift * h;
682+
if (dstShift > 1)
683+
{ dstShift = -1; }
682684

683-
if (split$1 > scaleMax)
684-
{ break; }
685+
split$1 -= dstShift * h;
685686

686-
prevHour = (prevHour + incrHours) % 24;
687+
prevHour = (prevHour + incrHours) % 24;
687688

688-
// add a tick only if it's further than 70% of the min allowed label spacing
689-
var prevSplit = splits[splits.length - 1];
690-
var pctIncr = round3((split$1 - prevSplit) / foundIncr);
689+
// add a tick only if it's further than 70% of the min allowed label spacing
690+
var prevSplit = splits[splits.length - 1];
691+
var pctIncr = round3((split$1 - prevSplit) / foundIncr);
691692

692-
if (pctIncr * pctSpace >= .7)
693+
if (pctIncr * pctSpace >= .7)
694+
{ splits.push(split$1); }
695+
}
696+
else
693697
{ splits.push(split$1); }
694698
}
695699
}

dist/uPlot.esm.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -673,27 +673,31 @@ function timeAxisSplits(tzDate) {
673673
while (1) {
674674
split = round3(split + foundIncr);
675675

676-
let expectedHour = floor(round6(prevHour + incrHours)) % 24;
677-
let splitDate = tzDate(split);
678-
let actualHour = splitDate.getHours();
676+
if (split > scaleMax)
677+
break;
679678

680-
let dstShift = actualHour - expectedHour;
679+
if (incrHours > 1) {
680+
let expectedHour = floor(round6(prevHour + incrHours)) % 24;
681+
let splitDate = tzDate(split);
682+
let actualHour = splitDate.getHours();
681683

682-
if (dstShift > 1)
683-
dstShift = -1;
684+
let dstShift = actualHour - expectedHour;
684685

685-
split -= dstShift * h;
686+
if (dstShift > 1)
687+
dstShift = -1;
686688

687-
if (split > scaleMax)
688-
break;
689+
split -= dstShift * h;
689690

690-
prevHour = (prevHour + incrHours) % 24;
691+
prevHour = (prevHour + incrHours) % 24;
691692

692-
// add a tick only if it's further than 70% of the min allowed label spacing
693-
let prevSplit = splits[splits.length - 1];
694-
let pctIncr = round3((split - prevSplit) / foundIncr);
693+
// add a tick only if it's further than 70% of the min allowed label spacing
694+
let prevSplit = splits[splits.length - 1];
695+
let pctIncr = round3((split - prevSplit) / foundIncr);
695696

696-
if (pctIncr * pctSpace >= .7)
697+
if (pctIncr * pctSpace >= .7)
698+
splits.push(split);
699+
}
700+
else
697701
splits.push(split);
698702
}
699703
}

dist/uPlot.iife.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -670,27 +670,31 @@ var uPlot = (function () {
670670
while (1) {
671671
split$1 = round3(split$1 + foundIncr);
672672

673-
var expectedHour = floor(round6(prevHour + incrHours)) % 24;
674-
var splitDate$1 = tzDate(split$1);
675-
var actualHour = splitDate$1.getHours();
673+
if (split$1 > scaleMax)
674+
{ break; }
676675

677-
var dstShift = actualHour - expectedHour;
676+
if (incrHours > 1) {
677+
var expectedHour = floor(round6(prevHour + incrHours)) % 24;
678+
var splitDate$1 = tzDate(split$1);
679+
var actualHour = splitDate$1.getHours();
678680

679-
if (dstShift > 1)
680-
{ dstShift = -1; }
681+
var dstShift = actualHour - expectedHour;
681682

682-
split$1 -= dstShift * h;
683+
if (dstShift > 1)
684+
{ dstShift = -1; }
683685

684-
if (split$1 > scaleMax)
685-
{ break; }
686+
split$1 -= dstShift * h;
686687

687-
prevHour = (prevHour + incrHours) % 24;
688+
prevHour = (prevHour + incrHours) % 24;
688689

689-
// add a tick only if it's further than 70% of the min allowed label spacing
690-
var prevSplit = splits[splits.length - 1];
691-
var pctIncr = round3((split$1 - prevSplit) / foundIncr);
690+
// add a tick only if it's further than 70% of the min allowed label spacing
691+
var prevSplit = splits[splits.length - 1];
692+
var pctIncr = round3((split$1 - prevSplit) / foundIncr);
692693

693-
if (pctIncr * pctSpace >= .7)
694+
if (pctIncr * pctSpace >= .7)
695+
{ splits.push(split$1); }
696+
}
697+
else
694698
{ splits.push(split$1); }
695699
}
696700
}

dist/uPlot.iife.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/opts.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,27 +230,31 @@ export function timeAxisSplits(tzDate) {
230230
while (1) {
231231
split = round3(split + foundIncr);
232232

233-
let expectedHour = floor(round6(prevHour + incrHours)) % 24;
234-
let splitDate = tzDate(split);
235-
let actualHour = splitDate.getHours();
233+
if (split > scaleMax)
234+
break;
236235

237-
let dstShift = actualHour - expectedHour;
236+
if (incrHours > 1) {
237+
let expectedHour = floor(round6(prevHour + incrHours)) % 24;
238+
let splitDate = tzDate(split);
239+
let actualHour = splitDate.getHours();
238240

239-
if (dstShift > 1)
240-
dstShift = -1;
241+
let dstShift = actualHour - expectedHour;
241242

242-
split -= dstShift * h;
243+
if (dstShift > 1)
244+
dstShift = -1;
243245

244-
if (split > scaleMax)
245-
break;
246+
split -= dstShift * h;
246247

247-
prevHour = (prevHour + incrHours) % 24;
248+
prevHour = (prevHour + incrHours) % 24;
248249

249-
// add a tick only if it's further than 70% of the min allowed label spacing
250-
let prevSplit = splits[splits.length - 1];
251-
let pctIncr = round3((split - prevSplit) / foundIncr);
250+
// add a tick only if it's further than 70% of the min allowed label spacing
251+
let prevSplit = splits[splits.length - 1];
252+
let pctIncr = round3((split - prevSplit) / foundIncr);
252253

253-
if (pctIncr * pctSpace >= .7)
254+
if (pctIncr * pctSpace >= .7)
255+
splits.push(split);
256+
}
257+
else
254258
splits.push(split);
255259
}
256260
}

0 commit comments

Comments
 (0)