Skip to content

Commit

Permalink
Merge pull request #4684 from plotly/rangebreaks-handle-date-heads
Browse files Browse the repository at this point in the history
Handle date heads on axes with rangebreaks
  • Loading branch information
archmoj authored Mar 25, 2020
2 parents 73db02a + 15d1f8c commit fbf6c92
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,24 +667,39 @@ axes.calcTicks = function calcTicks(ax) {
ax._prevDateHead = '';
ax._inCalcTicks = true;

var ticksOut = new Array(tickVals.length);
for(var i = 0; i < tickVals.length; i++) {
ticksOut[i] = axes.tickText(
var _value;
var _minor;
var calcTickText = function() {
return axes.tickText(
ax,
tickVals[i].value,
_value,
false, // hover
tickVals[i].minor // noSuffixPrefix
_minor // noSuffixPrefix
);
};

var prevDateHead;
var ticksOut = new Array(tickVals.length);
for(var i = 0; i < tickVals.length; i++) {
_minor = tickVals[i].minor;

_value = tickVals[i].value;
ticksOut[i] = calcTickText();

if(tickVals[i]._realV) {
// correct label
ticksOut[i].text = axes.tickText(
ax,
tickVals[i]._realV,
false, // hover
tickVals[i].minor // noSuffixPrefix
).text;
_value = tickVals[i]._realV;

var short = calcTickText().text;
ax._prevDateHead = '';
var long = calcTickText().text;

ticksOut[i].text = (
prevDateHead === ax._prevDateHead
) ? short : long;
}

prevDateHead = ax._prevDateHead;
}

ax._inCalcTicks = false;
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.
Binary file modified test/image/baselines/axes_breaks-night_autorange-reversed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/axes_breaks-weekends-weeknights.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fbf6c92

Please sign in to comment.