Commit fd02f179 authored by alain's avatar alain 🐙
Browse files

fix legend conditional

parent bd8510c1
......@@ -9,7 +9,6 @@ import { moment } from "../util/time.js"
const SensorTooltip = props => {
const { d, label, unit } = props
//const dataAgeText = d.dataAge < 1 ? texts.lastHour : `${roundBy(d.dataAge, 0)} ${texts.hoursAgo}`
const dataAgeText = `${ moment(d.timestamp).format("HH") }-${ moment(d.timestamp).add(1, 'hours').format("HH") }${texts.hourShort}`
return (
......
......@@ -286,7 +286,7 @@ class StationInfo extends React.Component {
<footer id="chart-footer">
<span className="hint-time-selection">{ texts.timeSelectionHint }</span>
{ Object.keys(dataStreams).length > 1 &&
{ Object.keys(dataStreams[Object.keys(dataStreams)[0]]).length > 1 &&
<ul id="chart-data-selection">
{ Object.keys(dataStreams).map(i =>
<li key={i} className="data-stream">
......
......@@ -84,3 +84,27 @@ export const subtractOneHourISO = (datestring) => {
// + 'T' + pad(now.getUTCHours())
// + ':00:00.000Z'
// }
export const getDataAge = (timestamp, granularity, timestamp_end = false) => {
const diff = new Date() - new Date(timestamp)
let unit
switch (granularity) {
case "minutely":
unit = 216000000
break;
case "daily":
unit = 150000
break;
// default is hourly
default:
unit = 3600000
break;
}
let inUnit = diff / unit
if(timestamp_end) inUnit -= unit
return inUnit
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment