Skip to content

Handle date heads on axes with rangebreaks #4684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.