From 3cbbae3f28dec7d482b352a814992c8cd3551a06 Mon Sep 17 00:00:00 2001 From: adamjhawley Date: Thu, 19 Oct 2023 00:06:07 +0300 Subject: [PATCH 1/2] Fix issue 6751: epoch date formats '%H:%M:%S' as 'undefined' This patch fixes issue #6751, where the epoch timestamp '1970-01-01 00:00:00', with 'hoverformat' '%H:%M:%S' is formatted as 'undefined'. Signed-off-by: adamjhawley --- src/plots/cartesian/axes.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index d3a56d04ad3..29627824766 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -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. @@ -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) { From 34532c72cf90206927a0d975d01aeefe8144054b Mon Sep 17 00:00:00 2001 From: adamjhawley Date: Thu, 19 Oct 2023 00:21:32 +0300 Subject: [PATCH 2/2] Add log entry for PR #6752 Signed-off-by: adamjhawley --- draftlogs/6751_fix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 draftlogs/6751_fix.md diff --git a/draftlogs/6751_fix.md b/draftlogs/6751_fix.md new file mode 100644 index 00000000000..824f4006de2 --- /dev/null +++ b/draftlogs/6751_fix.md @@ -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)] \ No newline at end of file