Skip to content

Commit

Permalink
position quarters in period mode - case of dtick set to M6
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Aug 31, 2020
1 parent b32b5a4 commit 350a10a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ axes.calcTicks = function calcTicks(ax, opts) {
} else if(definedDelta === ONEAVGQUARTER && delta >= ONEMINQUARTER) {
if(actualDelta >= ONEMINQUARTER && actualDelta <= ONEMAXQUARTER) {
periodLength = actualDelta;
} else {
periodLength = ONEAVGQUARTER;
}
} else if(delta >= ONEMINMONTH) {
if(actualDelta >= ONEMINMONTH && actualDelta <= ONEMAXMONTH) {
Expand Down
29 changes: 29 additions & 0 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5284,6 +5284,35 @@ describe('Test axes', function() {
.then(done);
});

it('should position quarters - case of dtick set to M6', function(done) {
Plotly.newPlot(gd, {
data: [{
hovertemplate: hovertemplate,
x: ['2020-01-01', '2022-01-01']
}],
layout: {
width: 1000,
xaxis: {
dtick: 'M6',
ticklabelmode: 'period',
tickformat: '%Y-Q%q'
}
}
})
.then(function() {
_assert('', [
'2019-08-15 15:45',
'2020-02-15 15:45',
'2020-08-15 15:45',
'2021-02-15 15:45',
'2021-08-15 15:45',
'2022-02-15 15:45'
], ['', '2020-Q1', '2020-Q3', '2021-Q1', '2021-Q3', '']);
})
.catch(failTest)
.then(done);
});

['%B', '%b', '%m'].forEach(function(formatter, i) {
it('should respect monthly tickformat that includes ' + formatter, function(done) {
Plotly.newPlot(gd, {
Expand Down

0 comments on commit 350a10a

Please sign in to comment.