Skip to content

Commit 350a10a

Browse files
committed
position quarters in period mode - case of dtick set to M6
1 parent b32b5a4 commit 350a10a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/plots/cartesian/axes.js

+2
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ axes.calcTicks = function calcTicks(ax, opts) {
794794
} else if(definedDelta === ONEAVGQUARTER && delta >= ONEMINQUARTER) {
795795
if(actualDelta >= ONEMINQUARTER && actualDelta <= ONEMAXQUARTER) {
796796
periodLength = actualDelta;
797+
} else {
798+
periodLength = ONEAVGQUARTER;
797799
}
798800
} else if(delta >= ONEMINMONTH) {
799801
if(actualDelta >= ONEMINMONTH && actualDelta <= ONEMAXMONTH) {

test/jasmine/tests/axes_test.js

+29
Original file line numberDiff line numberDiff line change
@@ -5284,6 +5284,35 @@ describe('Test axes', function() {
52845284
.then(done);
52855285
});
52865286

5287+
it('should position quarters - case of dtick set to M6', function(done) {
5288+
Plotly.newPlot(gd, {
5289+
data: [{
5290+
hovertemplate: hovertemplate,
5291+
x: ['2020-01-01', '2022-01-01']
5292+
}],
5293+
layout: {
5294+
width: 1000,
5295+
xaxis: {
5296+
dtick: 'M6',
5297+
ticklabelmode: 'period',
5298+
tickformat: '%Y-Q%q'
5299+
}
5300+
}
5301+
})
5302+
.then(function() {
5303+
_assert('', [
5304+
'2019-08-15 15:45',
5305+
'2020-02-15 15:45',
5306+
'2020-08-15 15:45',
5307+
'2021-02-15 15:45',
5308+
'2021-08-15 15:45',
5309+
'2022-02-15 15:45'
5310+
], ['', '2020-Q1', '2020-Q3', '2021-Q1', '2021-Q3', '']);
5311+
})
5312+
.catch(failTest)
5313+
.then(done);
5314+
});
5315+
52875316
['%B', '%b', '%m'].forEach(function(formatter, i) {
52885317
it('should respect monthly tickformat that includes ' + formatter, function(done) {
52895318
Plotly.newPlot(gd, {

0 commit comments

Comments
 (0)