Skip to content

Commit 4c10ddd

Browse files
committed
adjust period labels for the case of big gaps
1 parent c080bc5 commit 4c10ddd

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/plots/cartesian/axes.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,11 @@ axes.calcTicks = function calcTicks(ax, opts) {
844844
periodLength *= ratio;
845845
} else {
846846
// case of big gap
847-
periodLength = ratio * actualDelta;
847+
if(actualDelta === ax.dtick) {
848+
periodLength = ratio * actualDelta;
849+
} else {
850+
periodLength = ratio * (actualDelta + periodLength) / 2;
851+
}
848852
}
849853
}
850854

test/jasmine/tests/axes_test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5867,37 +5867,37 @@ describe('Test axes', function() {
58675867
[
58685868
{
58695869
range: ['2020-12-14 08:00', '2022-12-14 08:00'],
5870-
positions: ['2020-12-17 02:47:08.5714', '2021-03-19 20:51:25.7143', '2021-06-17 16:17:08.5714', '2021-09-17 12:00', '2021-12-19 11:08:34.2857', '2022-03-17 16:17:08.5714', '2022-06-17 16:17:08.5714', '2022-09-18 14:00', '2022-12-18 14:00'],
5871-
labels: ['Dec 2020', 'Mar 2021', 'Jun 2021', 'Sep 2021', 'Dec 2021', 'Mar 2022', 'Jun 2022', 'Sep 2022', '']
5870+
positions: ['2020-12-11 18:36:57.8571', '2021-03-13 15:20:53.5714', '2021-06-12 04:21:57.8571', '2021-09-12 02:13:23.5714', '2021-12-13 10:29:27.8571', '2022-03-12 04:21:57.8571', '2022-06-12 04:21:57.8571', '2022-09-12 19:34:17.1429', '2022-12-12 19:34:17.1429'],
5871+
labels: ['', 'Mar 2021', 'Jun 2021', 'Sep 2021', 'Dec 2021', 'Mar 2022', 'Jun 2022', 'Sep 2022', 'Dec 2022']
58725872
},
58735873
{
58745874
range: ['2020-12-14 08:00', '2021-08-14 08:00'],
5875-
positions: ['2020-12-08 17:21:25.7143', '2020-12-27 22:00', '2021-01-24 22:00', '2021-02-21 22:00', '2021-03-21 22:00', '2021-04-18 22:00', '2021-05-16 22:00', '2021-06-13 22:00', '2021-07-11 22:00', '2021-08-08 22:00'],
5875+
positions: ['2020-12-07 10:49:17.1429', '2020-12-27 22:00', '2021-01-24 22:00', '2021-02-21 22:00', '2021-03-21 22:00', '2021-04-18 22:00', '2021-05-16 22:00', '2021-06-13 22:00', '2021-07-11 22:00', '2021-08-08 22:00'],
58765876
labels: ['', 'Dec 21<br>2020', 'Jan 18<br>2021', 'Feb 15', 'Mar 15', 'Apr 12', 'May 10', 'Jun 7', 'Jul 5', 'Aug 2']
58775877
},
58785878
{
58795879
range: ['2020-12-14 08:00', '2021-04-14 08:00'],
5880-
positions: ['2020-12-14 06:38:34.2857', '2020-12-24 14:00', '2021-01-07 14:00', '2021-01-21 14:00', '2021-02-04 14:00', '2021-02-18 14:00', '2021-03-04 14:00', '2021-03-18 14:00', '2021-04-01 14:00', '2021-04-15 14:00'],
5881-
labels: ['', 'Dec 21<br>2020', 'Jan 4<br>2021', 'Jan 18', 'Feb 1', 'Feb 15', 'Mar 1', 'Mar 15', 'Mar 29', '']
5880+
positions: ['2020-12-13 17:10:42.8571', '2020-12-23 00:51:25.7143', '2021-01-06 00:51:25.7143', '2021-01-20 00:51:25.7143', '2021-02-03 00:51:25.7143', '2021-02-17 00:51:25.7143', '2021-03-03 00:51:25.7143', '2021-03-17 00:51:25.7143', '2021-03-31 00:51:25.7143', '2021-04-14 00:51:25.7143'],
5881+
labels: ['', 'Dec 21<br>2020', 'Jan 4<br>2021', 'Jan 18', 'Feb 1', 'Feb 15', 'Mar 1', 'Mar 15', 'Mar 29', 'Apr 12']
58825882
},
58835883
{
58845884
range: ['2020-12-14 08:00', '2021-02-14 08:00'],
5885-
positions: ['2020-12-14 06:38:34.2857', '2020-12-22 12:00', '2020-12-29 12:00', '2021-01-05 12:00', '2021-01-12 12:00', '2021-01-19 12:00', '2021-01-26 12:00', '2021-02-02 12:00', '2021-02-09 16:45:42.8571', '2021-02-15 18:45:42.8571'],
5885+
positions: ['2020-12-13 17:10:42.8571', '2020-12-22 12:00', '2020-12-29 12:00', '2021-01-05 12:00', '2021-01-12 12:00', '2021-01-19 12:00', '2021-01-26 12:00', '2021-02-02 12:00', '2021-02-09 02:14:17.1429', '2021-02-15 04:14:17.1429'],
58865886
labels: ['', 'Dec 21<br>2020', 'Dec 28', 'Jan 4<br>2021', 'Jan 11', 'Jan 18', 'Jan 25', 'Feb 1', 'Feb 8', '']
58875887
},
58885888
{
58895889
range: ['2020-12-14 08:00', '2021-01-14 08:00'],
5890-
positions: ['2020-12-14 11:34:17.1429', '2020-12-16 12:17:08.5714', '2020-12-18 18:34:17.1429', '2020-12-22 12:17:08.5714', '2020-12-24 18:34:17.1429', '2020-12-28 12:17:08.5714', '2020-12-30 12:17:08.5714', '2021-01-01 18:34:17.1429', '2021-01-05 12:17:08.5714', '2021-01-07 18:34:17.1429', '2021-01-11 12:17:08.5714', '2021-01-13 12:17:08.5714'],
5890+
positions: ['2020-12-14 08:21:25.7143', '2020-12-16 12:17:08.5714', '2020-12-18 13:51:25.7143', '2020-12-22 12:17:08.5714', '2020-12-24 13:51:25.7143', '2020-12-28 12:17:08.5714', '2020-12-30 12:17:08.5714', '2021-01-01 13:51:25.7143', '2021-01-05 12:17:08.5714', '2021-01-07 13:51:25.7143', '2021-01-11 12:17:08.5714', '2021-01-13 12:17:08.5714'],
58915891
labels: ['Dec 14<br>2020', 'Dec 16', 'Dec 18', 'Dec 22', 'Dec 24', 'Dec 28', 'Dec 30', 'Jan 1<br>2021', 'Jan 5', 'Jan 7', 'Jan 11', 'Jan 13']
58925892
},
58935893
{
58945894
range: ['2020-12-14 08:00', '2021-01-01 08:00'],
5895-
positions: ['2020-12-14 11:34:17.1429', '2020-12-16 12:17:08.5714', '2020-12-18 18:34:17.1429', '2020-12-22 12:17:08.5714', '2020-12-24 18:34:17.1429', '2020-12-28 12:17:08.5714', '2020-12-30 12:17:08.5714', '2021-01-01 12:17:08.5714'],
5895+
positions: ['2020-12-14 08:21:25.7143', '2020-12-16 12:17:08.5714', '2020-12-18 13:51:25.7143', '2020-12-22 12:17:08.5714', '2020-12-24 13:51:25.7143', '2020-12-28 12:17:08.5714', '2020-12-30 12:17:08.5714', '2021-01-01 12:17:08.5714'],
58965896
labels: ['Dec 14<br>2020', 'Dec 16', 'Dec 18', 'Dec 22', 'Dec 24', 'Dec 28', 'Dec 30', '']
58975897
},
58985898
{
58995899
range: ['2020-12-14 08:00', '2020-12-22 08:00'],
5900-
positions: ['2020-12-14 06:04:17.1429', '2020-12-15 12:00', '2020-12-16 12:00', '2020-12-17 12:00', '2020-12-18 12:00', '2020-12-21 12:00', '2020-12-22 12:00'],
5900+
positions: ['2020-12-14 05:27:51.4286', '2020-12-15 12:00', '2020-12-16 12:00', '2020-12-17 12:00', '2020-12-18 10:00', '2020-12-21 12:00', '2020-12-22 12:00'],
59015901
labels: ['', '06:00<br>Dec 15, 2020', '06:00<br>Dec 16, 2020', '06:00<br>Dec 17, 2020', '06:00<br>Dec 18, 2020', '06:00<br>Dec 21, 2020', '']
59025902
},
59035903
{

0 commit comments

Comments
 (0)