diff --git a/src/components/info/info.js b/src/components/info/info.js index 9703fef22..4eb69b49f 100644 --- a/src/components/info/info.js +++ b/src/components/info/info.js @@ -20,9 +20,13 @@ const pluralise = (word, n) => { }; const styliseDateRange = (dateStr) => { - // 2012-01-22 const fields = dateStr.split('-'); - return `${months[fields[1]]} ${fields[0]}`; + // 2012-01-22 + if (fields.length==3){ + return `${months[fields[1]]} ${fields[0]}`; + }else{ // other cases like negative numbers + return dateStr; + } }; const getNumSelectedTips = (nodes, visibility) => { diff --git a/src/util/dateHelpers.js b/src/util/dateHelpers.js index 5668cb0b6..0972b9ea3 100644 --- a/src/util/dateHelpers.js +++ b/src/util/dateHelpers.js @@ -8,6 +8,9 @@ const dateScale = scaleTime() .range([2000, 2100]); export const numericToCalendar = (numDate) => { + if (numDate<0){ + return Math.round(numDate).toString(); + } const d3Date = dateScale.invert(numDate); const calDate = dateFormatter(d3Date); return calDate;