Skip to content

Commit

Permalink
Merge pull request #6752 from adamjhawley/fix-undef-date-hover
Browse files Browse the repository at this point in the history
Fix issue 6751: epoch date formats '%H:%M:%S' as 'undefined'
  • Loading branch information
archmoj authored Oct 20, 2023
2 parents 9b0b2ff + 34532c7 commit 80179d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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

0 comments on commit 80179d5

Please sign in to comment.