Skip to content

Commit c62896b

Browse files
committed
fix #2892 - don't allow auto date ticks < our 100 microseconds limit
1 parent 27c9e55 commit c62896b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/plots/cartesian/axes.js

+3
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,9 @@ axes.autoTicks = function(ax, roughDTick) {
692692
base = getBase(10);
693693
ax.dtick = roundDTick(roughDTick, base, roundBase10);
694694
}
695+
// ensure we don't try to make ticks below our minimum precision
696+
// see https://github.com/plotly/plotly.js/issues/2892
697+
if(ax.dtick < 0.1) ax.dtick = 0.1;
695698
}
696699
else if(ax.type === 'log') {
697700
ax.tick0 = 0;

test/jasmine/tests/axes_test.js

+13
Original file line numberDiff line numberDiff line change
@@ -2057,6 +2057,19 @@ describe('Test axes', function() {
20572057
expect(textOut).toEqual(expectedText);
20582058
});
20592059

2060+
it('never gives date dtick < 100 microseconds', function() {
2061+
var ax = {
2062+
type: 'date',
2063+
tickmode: 'auto',
2064+
nticks: '100',
2065+
range: ['2017-02-08 05:21:18.145', '2017-02-08 05:21:18.1451']
2066+
};
2067+
2068+
var textOut = mockCalc(ax);
2069+
var expectedText = ['05:21:18.145<br>Feb 8, 2017', '05:21:18.1451'];
2070+
expect(textOut).toEqual(expectedText);
2071+
});
2072+
20602073
it('should handle edge cases with dates and tickvals', function() {
20612074
var ax = {
20622075
type: 'date',

0 commit comments

Comments
 (0)