Skip to content

Commit

Permalink
Fix issue 6751: epoch date formats '%H:%M:%S' as 'undefined'
Browse files Browse the repository at this point in the history
This patch fixes issue plotly#6751, where the epoch timestamp '1970-01-01 00:00:00',
with 'hoverformat' '%H:%M:%S' is formatted as 'undefined'.

Signed-off-by: adamjhawley <[email protected]>
  • Loading branch information
adamjhawley committed Oct 18, 2023
1 parent 630b092 commit 3cbbae3
Showing 1 changed file with 4 additions and 1 deletion.
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 3cbbae3

Please sign in to comment.