Skip to content

Commit

Permalink
fix 'increase dtick' lgoic for cases with dtick value starting 'M'
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Mar 12, 2020
1 parent 40d57fa commit 1b55b42
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,9 @@ axes.prepTicks = function(ax) {
// have explicit tickvals without tick text
if(ax.tickmode === 'array') nt *= 100;

axes.autoTicks(ax, (Math.abs(rng[1] - rng[0]) - (ax._lBreaks || 0)) / nt);

ax._roughDTick = (Math.abs(rng[1] - rng[0]) - (ax._lBreaks || 0)) / nt;
axes.autoTicks(ax, ax._roughDTick);

// check for a forced minimum dtick
if(ax._minDtick > 0 && ax.dtick < ax._minDtick * 2) {
Expand Down Expand Up @@ -620,7 +622,8 @@ axes.calcTicks = function calcTicks(ax) {
// increase dtick to generate more ticks,
// so that some hopefully fall between breaks
if(ax.tickmode === 'auto' && tickVals.length < nTicksBefore / 6) {
ax.dtick /= 2;
axes.autoTicks(ax, ax._roughDTick / 3);
autoTickRound(ax);
ax._tmin = axes.tickFirst(ax);
generateTicks();
tickVals = tickVals.filter(function(d) {
Expand Down
Binary file modified test/image/baselines/axes_breaks-finance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4880,8 +4880,8 @@ describe('Test axes', function() {
.then(function() {
_assert('with breaks enabled on x-axis', {
tickVals: [
1483531200000, 1484136000000, 1484740800000, 1485345600000,
1485950400000, 1486555200000, 1487160000000
1483574400000, 1484092800000, 1484611200000, 1484870400000,
1485388800000, 1485907200000, 1486425600000, 1486684800000
]
});
})
Expand Down

0 comments on commit 1b55b42

Please sign in to comment.