Skip to content

Commit 7febd59

Browse files
committed
add tests for auto labels and rangebreaks
1 parent 104ae5e commit 7febd59

File tree

1 file changed

+224
-0
lines changed

1 file changed

+224
-0
lines changed

test/jasmine/tests/axes_test.js

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5530,6 +5530,230 @@ describe('Test axes', function() {
55305530
.then(done);
55315531
});
55325532
});
5533+
5534+
[
5535+
{
5536+
range: ['2020-12-15', '2084-12-15'],
5537+
positions: ['2020-07-01 15:00', '2030-07-02 15:00', '2040-07-01 15:00', '2050-07-02 15:00', '2060-07-01 15:00', '2070-07-02 15:00', '2080-07-01 15:00'],
5538+
labels: ['', '2030', '2040', '2050', '2060', '2070', '2080']
5539+
},
5540+
{
5541+
range: ['2020-12-15', '2052-12-15'],
5542+
positions: ['2020-07-01 15:00', '2025-07-02 15:00', '2030-07-02 15:00', '2035-07-02 15:00', '2040-07-01 15:00', '2045-07-02 15:00', '2050-07-02 15:00'],
5543+
labels: ['', '2025', '2030', '2035', '2040', '2045', '2050']
5544+
},
5545+
{
5546+
range: ['2020-12-15', '2036-12-15'],
5547+
positions: ['2020-07-01 15:00', '2022-07-02 15:00', '2024-07-01 15:00', '2026-07-02 15:00', '2028-07-01 15:00', '2030-07-02 15:00', '2032-07-01 15:00', '2034-07-02 15:00', '2036-07-01 15:00'],
5548+
labels: ['', '2022', '2024', '2026', '2028', '2030', '2032', '2034', '2036']
5549+
},
5550+
{
5551+
range: ['2020-12-15', '2028-12-15'],
5552+
positions: ['2020-07-02', '2021-07-02 12:00', '2022-07-02 12:00', '2023-07-02 12:00', '2024-07-02', '2025-07-02 12:00', '2026-07-02 12:00', '2027-07-02 12:00', '2028-07-01 12:00'],
5553+
labels: ['', '2021', '2022', '2023', '2024', '2025', '2026', '2027', '2028']
5554+
},
5555+
{
5556+
range: ['2020-12-15', '2024-12-15'],
5557+
positions: ['2020-07-16 05:15', '2021-01-16 05:15', '2021-07-16 05:15', '2022-01-16 05:15', '2022-07-16 05:15', '2023-01-16 05:15', '2023-07-16 05:15', '2024-01-16 05:15', '2024-07-16 05:15'],
5558+
labels: ['', 'Jan 2021', 'Jul 2021', 'Jan 2022', 'Jul 2022', 'Jan 2023', 'Jul 2023', 'Jan 2024', 'Jul 2024']
5559+
},
5560+
{
5561+
range: ['2020-12-15', '2022-12-15'],
5562+
positions: ['2020-10-16 05:15', '2021-01-16 05:15', '2021-04-16 05:15', '2021-07-16 05:15', '2021-10-16 05:15', '2022-01-16 05:15', '2022-04-16 05:15', '2022-07-16 05:15', '2022-10-16 05:15'],
5563+
labels: ['', 'Jan 2021', 'Apr 2021', 'Jul 2021', 'Oct 2021', 'Jan 2022', 'Apr 2022', 'Jul 2022', 'Oct 2022']
5564+
},
5565+
{
5566+
range: ['2020-12-15', '2021-12-15'],
5567+
positions: ['2020-11-16 05:15', '2021-01-16 05:15', '2021-03-16 05:15', '2021-05-16 05:15', '2021-07-16 05:15', '2021-09-16 05:15', '2021-11-16 05:15'],
5568+
labels: ['', 'Jan 2021', 'Mar 2021', 'May 2021', 'Jul 2021', 'Sep 2021', 'Nov 2021']
5569+
},
5570+
{
5571+
range: ['2020-12-15', '2021-06-15'],
5572+
positions: ['2020-12-16 12:00', '2021-01-16 12:00', '2021-02-15', '2021-03-16 12:00', '2021-04-16', '2021-05-16 12:00', '2021-06-16 12:00'],
5573+
labels: ['Dec 2020', 'Jan 2021', 'Feb 2021', 'Mar 2021', 'Apr 2021', 'May 2021', '']
5574+
},
5575+
{
5576+
range: ['2020-12-15', '2021-02-15'],
5577+
positions: ['2020-12-13 12:00', '2020-12-20 12:00', '2020-12-27 12:00', '2021-01-03 12:00', '2021-01-10 12:00', '2021-01-17 12:00', '2021-01-24 12:00', '2021-01-31 12:00', '2021-02-07 12:00', '2021-02-14 12:00'],
5578+
labels: ['', 'Dec 20<br>2020', 'Dec 27', 'Jan 3<br>2021', 'Jan 10', 'Jan 17', 'Jan 24', 'Jan 31', 'Feb 7', 'Feb 14']
5579+
},
5580+
{
5581+
range: ['2020-12-15', '2021-01-15'],
5582+
positions: ['2020-12-13 12:00', '2020-12-20 12:00', '2020-12-27 12:00', '2021-01-03 12:00', '2021-01-10 12:00'],
5583+
labels: ['', 'Dec 20<br>2020', 'Dec 27', 'Jan 3<br>2021', 'Jan 10']
5584+
},
5585+
{
5586+
range: ['2020-12-15', '2021-01-01'],
5587+
positions: ['2020-12-14 12:00', '2020-12-16 12:00', '2020-12-18 12:00', '2020-12-20 12:00', '2020-12-22 12:00', '2020-12-24 12:00', '2020-12-26 12:00', '2020-12-28 12:00', '2020-12-30 12:00', '2021-01-01 12:00'],
5588+
labels: ['', 'Dec 16<br>2020', 'Dec 18', 'Dec 20', 'Dec 22', 'Dec 24', 'Dec 26', 'Dec 28', 'Dec 30', '']
5589+
},
5590+
{
5591+
range: ['2020-12-15', '2020-12-21'],
5592+
positions: ['2020-12-14 12:00', '2020-12-15 12:00', '2020-12-16 12:00', '2020-12-17 12:00', '2020-12-18 12:00', '2020-12-19 12:00', '2020-12-20 12:00', '2020-12-21 12:00'],
5593+
labels: ['', 'Dec 15<br>2020', 'Dec 16', 'Dec 17', 'Dec 18', 'Dec 19', 'Dec 20', '']
5594+
},
5595+
{
5596+
range: ['2020-12-15', '2020-12-16'],
5597+
positions: ['2020-12-14 21:00', '2020-12-15', '2020-12-15 03:00', '2020-12-15 06:00', '2020-12-15 09:00', '2020-12-15 12:00', '2020-12-15 15:00', '2020-12-15 18:00', '2020-12-15 21:00', '2020-12-16'],
5598+
labels: ['', '00:00<br>Dec 15, 2020', '03:00', '06:00', '09:00', '12:00', '15:00', '18:00', '21:00', '00:00<br>Dec 16, 2020']
5599+
},
5600+
{
5601+
range: ['2020-12-15', '2020-12-15 12:00'],
5602+
positions: ['2020-12-14 22:00', '2020-12-15', '2020-12-15 02:00', '2020-12-15 04:00', '2020-12-15 06:00', '2020-12-15 08:00', '2020-12-15 10:00', '2020-12-15 12:00'],
5603+
labels: ['', '00:00<br>Dec 15, 2020', '02:00', '04:00', '06:00', '08:00', '10:00', '12:00']
5604+
}
5605+
].forEach(function(t) {
5606+
it('should position auto labels | range:' + t.range, function(done) {
5607+
Plotly.newPlot(gd, {
5608+
data: [{
5609+
x: [
5610+
'2020-12-15',
5611+
'2020-12-15 0:45',
5612+
'2020-12-15 1:30',
5613+
'2020-12-15 3:00',
5614+
'2020-12-15 6:00',
5615+
'2020-12-15 12:00',
5616+
'2020-12-16',
5617+
'2020-12-18',
5618+
'2020-12-24',
5619+
'2021-01-01',
5620+
'2021-01-15',
5621+
'2021-02-15',
5622+
'2021-03-15',
5623+
'2021-04-15',
5624+
'2021-05-15',
5625+
'2021-06-15',
5626+
'2021-07-01',
5627+
'2022-07-01',
5628+
'2023-07-01',
5629+
'2024-07-01',
5630+
'2025-07-01',
5631+
'2030-07-01',
5632+
'2035-07-01',
5633+
'2040-07-01',
5634+
'2080-07-01',
5635+
'2160-07-01'
5636+
]
5637+
}],
5638+
layout: {
5639+
width: 1000,
5640+
xaxis: {
5641+
ticklabelmode: 'period',
5642+
range: t.range
5643+
}
5644+
}
5645+
})
5646+
.then(function() {
5647+
_assert('', t.positions, t.labels);
5648+
})
5649+
.catch(failTest)
5650+
.then(done);
5651+
});
5652+
});
5653+
5654+
[
5655+
{
5656+
range: ['2020-12-14 08:00', '2022-12-14 08:00'],
5657+
positions: ['2020-12-06 10:26:47.1429', '2021-03-07 09:50:21.4286', '2021-06-06 16:26:47.1429', '2021-09-06 16:26:47.1429', '2021-12-07 09:50:21.4286', '2022-03-06 16:26:47.1429', '2022-06-06 16:26:47.1429', '2022-09-07 01:08:34.2857', '2022-12-07 01:08:34.2857'],
5658+
labels: ['', 'Mar 2021', 'Jun 2021', 'Sep 2021', 'Dec 2021', 'Mar 2022', 'Jun 2022', 'Sep 2022', 'Dec 2022']
5659+
},
5660+
{
5661+
range: ['2020-12-14 08:00', '2021-08-14 08:00'],
5662+
positions: ['2020-12-06 04:17:08.5714', '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'],
5663+
labels: ['', 'Dec 21<br>2020', 'Jan 18<br>2021', 'Feb 15', 'Mar 15', 'Apr 12', 'May 10', 'Jun 7', 'Jul 5', 'Aug 2']
5664+
},
5665+
{
5666+
range: ['2020-12-14 08:00', '2021-04-14 08:00'],
5667+
positions: ['2020-12-13 03:42:51.4286', '2020-12-21 11:42:51.4286', '2021-01-04 11:42:51.4286', '2021-01-18 11:42:51.4286', '2021-02-01 11:42:51.4286', '2021-02-15 11:42:51.4286', '2021-03-01 11:42:51.4286', '2021-03-15 11:42:51.4286', '2021-03-29 11:42:51.4286', '2021-04-12 11:42:51.4286'],
5668+
labels: ['', 'Dec 21<br>2020', 'Jan 4<br>2021', 'Jan 18', 'Feb 1', 'Feb 15', 'Mar 1', 'Mar 15', 'Mar 29', 'Apr 12']
5669+
},
5670+
{
5671+
range: ['2020-12-14 08:00', '2021-02-14 08:00'],
5672+
positions: ['2020-12-13 03:42:51.4286', '2020-12-21 10:17:08.5714', '2020-12-28 10:17:08.5714', '2021-01-04 10:17:08.5714', '2021-01-11 10:17:08.5714', '2021-01-18 10:17:08.5714', '2021-01-25 10:17:08.5714', '2021-02-01 10:17:08.5714', '2021-02-08 11:42:51.4286', '2021-02-14 13:42:51.4286'],
5673+
labels: ['', 'Dec 21<br>2020', 'Dec 28', 'Jan 4<br>2021', 'Jan 11', 'Jan 18', 'Jan 25', 'Feb 1', 'Feb 8', '']
5674+
},
5675+
{
5676+
range: ['2020-12-14 08:00', '2021-01-14 08:00'],
5677+
positions: ['2020-12-14 05:08:34.2857', '2020-12-16 12:17:08.5714', '2020-12-18 09:08:34.2857', '2020-12-22 12:17:08.5714', '2020-12-24 09:08:34.2857', '2020-12-28 12:17:08.5714', '2020-12-30 12:17:08.5714', '2021-01-01 09:08:34.2857', '2021-01-05 12:17:08.5714', '2021-01-07 09:08:34.2857', '2021-01-11 12:17:08.5714', '2021-01-13 12:17:08.5714'],
5678+
labels: ['', 'Dec 16<br>2020', 'Dec 18', 'Dec 22', 'Dec 24', 'Dec 28', 'Dec 30', 'Jan 1<br>2021', 'Jan 5', 'Jan 7', 'Jan 11', 'Jan 13']
5679+
},
5680+
{
5681+
range: ['2020-12-14 08:00', '2021-01-01 08:00'],
5682+
positions: ['2020-12-14 05:08:34.2857', '2020-12-16 12:17:08.5714', '2020-12-18 09:08:34.2857', '2020-12-22 12:17:08.5714', '2020-12-24 09:08:34.2857', '2020-12-28 12:17:08.5714', '2020-12-30 12:17:08.5714', '2021-01-01 12:17:08.5714'],
5683+
labels: ['', 'Dec 16<br>2020', 'Dec 18', 'Dec 22', 'Dec 24', 'Dec 28', 'Dec 30', '']
5684+
},
5685+
{
5686+
range: ['2020-12-14 08:00', '2020-12-22 08:00'],
5687+
positions: ['2020-12-14 04:51:25.7143', '2020-12-15 12:00', '2020-12-16 12:00', '2020-12-17 12:00', '2020-12-18 08:00', '2020-12-21 12:00', '2020-12-22 12:00'],
5688+
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', '']
5689+
},
5690+
{
5691+
range: ['2020-12-14 08:00', '2020-12-18 08:00'],
5692+
positions: ['2020-12-14 06:00', '2020-12-14 12:00', '2020-12-15 06:00', '2020-12-15 12:00', '2020-12-16 06:00', '2020-12-16 12:00', '2020-12-17 06:00', '2020-12-17 12:00', '2020-12-18 06:00'],
5693+
labels: ['', '12:00<br>Dec 14, 2020', '06:00<br>Dec 15, 2020', '12:00', '06:00<br>Dec 16, 2020', '12:00', '06:00<br>Dec 17, 2020', '12:00', '06:00<br>Dec 18, 2020']
5694+
},
5695+
{
5696+
range: ['2020-12-14 08:00', '2020-12-16 08:00'],
5697+
positions: ['2020-12-14 06:00', '2020-12-14 09:00', '2020-12-14 12:00', '2020-12-14 15:00', '2020-12-15 06:00', '2020-12-15 09:00', '2020-12-15 12:00', '2020-12-15 15:00', '2020-12-16 06:00'],
5698+
labels: ['', '09:00<br>Dec 14, 2020', '12:00', '15:00', '06:00<br>Dec 15, 2020', '09:00', '12:00', '15:00', '06:00<br>Dec 16, 2020']
5699+
}
5700+
].forEach(function(t) {
5701+
it('should position auto labels with rangebreaks | range:' + t.range, function(done) {
5702+
Plotly.newPlot(gd, {
5703+
data: [{
5704+
x: [
5705+
'2020-12-14 08:00', '2020-12-14 12:00', '2020-12-14 16:00',
5706+
'2020-12-15 08:00', '2020-12-15 12:00', '2020-12-15 16:00',
5707+
'2020-12-16 08:00', '2020-12-16 12:00', '2020-12-16 16:00',
5708+
'2020-12-17 08:00', '2020-12-17 12:00', '2020-12-17 16:00',
5709+
'2020-12-18 08:00', '2020-12-18 12:00', '2020-12-18 16:00',
5710+
5711+
'2020-12-21 08:00', '2020-12-21 12:00', '2020-12-21 16:00',
5712+
'2020-12-22 08:00', '2020-12-22 12:00', '2020-12-22 16:00',
5713+
'2020-12-23 08:00', '2020-12-23 12:00', '2020-12-23 16:00',
5714+
'2020-12-24 08:00', '2020-12-24 12:00', '2020-12-24 16:00',
5715+
'2020-12-25 08:00', '2020-12-25 12:00', '2020-12-25 16:00',
5716+
5717+
'2020-12-28 08:00', '2020-12-28 12:00', '2020-12-28 16:00',
5718+
'2020-12-29 08:00', '2020-12-29 12:00', '2020-12-29 16:00',
5719+
'2020-12-30 08:00', '2020-12-30 12:00', '2020-12-30 16:00',
5720+
'2020-12-31 08:00', '2020-12-31 12:00', '2020-12-31 16:00',
5721+
'2021-01-01 08:00', '2021-01-01 12:00', '2021-01-01 16:00',
5722+
5723+
'2021-01-04 08:00', '2021-01-04 12:00', '2021-01-04 16:00',
5724+
'2021-01-05 08:00', '2021-01-05 12:00', '2021-01-05 16:00',
5725+
'2021-01-06 08:00', '2021-01-06 12:00', '2021-01-06 16:00',
5726+
'2021-01-07 08:00', '2021-01-07 12:00', '2021-01-07 16:00',
5727+
'2021-01-08 08:00', '2021-01-08 12:00', '2021-01-08 16:00',
5728+
5729+
'2021-01-11 08:00', '2021-01-11 12:00', '2021-01-11 16:00',
5730+
'2021-01-12 08:00', '2021-01-12 12:00', '2021-01-12 16:00',
5731+
'2021-01-13 08:00', '2021-01-13 12:00', '2021-01-13 16:00',
5732+
'2021-01-14 08:00', '2021-01-14 12:00', '2021-01-14 16:00',
5733+
'2021-01-15 08:00', '2021-01-15 12:00', '2021-01-15 16:00',
5734+
]
5735+
}],
5736+
layout: {
5737+
width: 1000,
5738+
xaxis: {
5739+
rangebreaks: [{
5740+
bounds: ['sat', 'mon']
5741+
}, {
5742+
bounds: [18, 6],
5743+
pattern: 'hour'
5744+
}],
5745+
ticklabelmode: 'period',
5746+
range: t.range
5747+
}
5748+
}
5749+
})
5750+
.then(function() {
5751+
_assert('', t.positions, t.labels);
5752+
})
5753+
.catch(failTest)
5754+
.then(done);
5755+
});
5756+
});
55335757
});
55345758
});
55355759

0 commit comments

Comments
 (0)