Skip to content

Commit 80179d5

Browse files
authoredOct 20, 2023
Merge pull request #6752 from adamjhawley/fix-undef-date-hover
Fix issue 6751: epoch date formats '%H:%M:%S' as 'undefined'
2 parents 9b0b2ff + 34532c7 commit 80179d5

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
 

‎draftlogs/6751_fix.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Timestamp '1970-01-01 00:00:00' formats hoverformat '%H:%M:%S' as 'undefined' [[#6752](https://github.com/plotly/plotly.js/pull/6752)]

‎src/plots/cartesian/axes.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,9 @@ function formatDate(ax, out, hover, extraPrecision) {
17441744
var tr = ax._tickround;
17451745
var fmt = (hover && ax.hoverformat) || axes.getTickFormat(ax);
17461746

1747+
// Only apply extra precision if no explicit format was provided.
1748+
extraPrecision = !fmt && extraPrecision;
1749+
17471750
if(extraPrecision) {
17481751
// second or sub-second precision: extra always shows max digits.
17491752
// for other fields, extra precision just adds one field.
@@ -1768,7 +1771,7 @@ function formatDate(ax, out, hover, extraPrecision) {
17681771
// anything to be uniform with!)
17691772

17701773
// can we remove the whole time part?
1771-
if(dateStr === '00:00:00' || dateStr === '00:00') {
1774+
if(headStr !== undefined && (dateStr === '00:00:00' || dateStr === '00:00')) {
17721775
dateStr = headStr;
17731776
headStr = '';
17741777
} else if(dateStr.length === 8) {

0 commit comments

Comments
 (0)
Please sign in to comment.