Skip to content
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

Fix issue 6751: epoch date formats '%H:%M:%S' as 'undefined' #6752

Merged
merged 2 commits into from
Oct 20, 2023
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
1 change: 1 addition & 0 deletions draftlogs/6751_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Timestamp '1970-01-01 00:00:00' formats hoverformat '%H:%M:%S' as 'undefined' [[#6752](https://github.com/plotly/plotly.js/pull/6752)]
5 changes: 4 additions & 1 deletion src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,9 @@ function formatDate(ax, out, hover, extraPrecision) {
var tr = ax._tickround;
var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax);

// Only apply extra precision if no explicit format was provided.
extraPrecision = !fmt && extraPrecision;

if(extraPrecision) {
// second or sub-second precision: extra always shows max digits.
// for other fields, extra precision just adds one field.
Expand All @@ -1768,7 +1771,7 @@ function formatDate(ax, out, hover, extraPrecision) {
// anything to be uniform with!)

// can we remove the whole time part?
if(dateStr === '00:00:00' || dateStr === '00:00') {
if(headStr !== undefined && (dateStr === '00:00:00' || dateStr === '00:00')) {
dateStr = headStr;
headStr = '';
} else if(dateStr.length === 8) {
Expand Down