From 6cb28a7408ab9aaa03b5291b0965b3f043201aa5 Mon Sep 17 00:00:00 2001 From: James Hadfield Date: Fri, 1 Jun 2018 15:38:28 -0700 Subject: [PATCH] Fix hover date off-by-one bug. Closes #572 --- src/components/tree/infoPanels/hover.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/tree/infoPanels/hover.js b/src/components/tree/infoPanels/hover.js index 8618e07f6..78a66e88f 100644 --- a/src/components/tree/infoPanels/hover.js +++ b/src/components/tree/infoPanels/hover.js @@ -33,22 +33,24 @@ const getBranchDivJSX = (d) =>

{infoLineJSX("Divergence:", prettyString(d.attr.div.toExponential(3)))}

; const getBranchTimeJSX = (d, temporalConfidence) => { - const dates = [numericToCalendar(d.attr.num_date)]; + const date = d.attr.date || numericToCalendar(d.attr.num_date); + let dateRange = false; if (temporalConfidence) { - dates[1] = numericToCalendar(d.attr.num_date_confidence[0]); - dates[2] = numericToCalendar(d.attr.num_date_confidence[1]); - if (dates[1] === dates[2]) { - return

{infoLineJSX("Date:", dates[0])}

; - } + dateRange = [ + numericToCalendar(d.attr.num_date_confidence[0]), + numericToCalendar(d.attr.num_date_confidence[1]) + ]; + } + if (dateRange && dateRange[0] !== dateRange[1]) { return (

- {infoLineJSX("Inferred Date:", dates[0])} + {infoLineJSX("Inferred Date:", date)}
- {infoLineJSX("Date Confidence Interval:", `(${dates[1]}, ${dates[2]})`)} + {infoLineJSX("Date Confidence Interval:", `(${dateRange[0]}, ${dateRange[1]})`)}

); } - return

{infoLineJSX("Date:", dates[0])}

; + return (

{infoLineJSX("Date:", date)}

); }; /**