Commit 79d7baf5 authored by alain's avatar alain 🐙
Browse files

merge

parents 86b054ee 206f5ecf
......@@ -8,6 +8,7 @@ export const texts = {
loading: "Bezig met laden...",
loadingError: "Laden mislukt...",
loadingRetry: "Probeer opnieuw",
nodata: "Geen data...",
lastMean: "laatste uurgemiddelde",
lastPeak: "piekwaarde laatste uur",
mean: "gemiddelde",
......
......@@ -18,10 +18,10 @@ const ChartTooltip = (props) => {
if (active) {
let avg, max
if(payload.length > 1) {
if(payload && payload.length > 1) {
avg = payload[1].value
max = payload[0].value[1]
} else if(payload.length > 0) {
} else if(payload && payload.length > 0) {
avg = payload[0].value
} else {
avg = "geen data"
......
......@@ -70,10 +70,12 @@ class StationInfo extends React.Component {
if(this.mounted) {
this.setState({ data, stationMeta, unit })
const startIndex = (data.length - 7*24 > 0 ? data.length - 7*24 : 0)
const dataStart = moment(data[startIndex].timestamp)
const dataEnd = moment(data[data.length-1].timestamp)
this.setTickSettings(dataStart, dataEnd)
if(data.length > 0) {
const startIndex = (data.length - 7*24 > 0 ? data.length - 7*24 : 0)
const dataStart = moment(data[startIndex].timestamp)
const dataEnd = moment(data[data.length-1].timestamp)
this.setTickSettings(dataStart, dataEnd)
}
}
})
}
......@@ -136,16 +138,17 @@ class StationInfo extends React.Component {
render() {
moment().locale("nl", localization)
if(!this.state.unit) return null
const { stationMeta, data, chartHeight, downloadForm, unit } = this.state
const { id, source } = this.props.clickedObject
const parameter = this.props.activeLayer
const yScale = (unit && unit.scale === 'log' ? scaleLog().domain(unit.range) : scaleLinear().domain(unit.range))
let yScale = scaleLinear()
if(unit) {
yScale = (unit.scale === 'log' ? scaleLog().domain(unit.range) : scaleLinear().domain(unit.range))
}
const lineStyle = (data && data[0].minmax ? { stroke:"#000000" } : { stroke:"url(#yaxis)" } )
const lineClass = (data && data[0].minmax ? "dashed" : "solid" )
const lineStyle = (data && data.length > 0 && data[0].minmax ? { stroke:"#000000" } : { stroke:"url(#yaxis)" } )
const lineClass = (data && data.length > 0 && data[0].minmax ? "dashed" : "solid" )
const sourceObject = this.props.activeLayer.sources.find(o => {
return o.name === source
......@@ -187,7 +190,7 @@ class StationInfo extends React.Component {
</div>
}
{ data ?
{ data && data.length > 0 ?
<div>
<div id="chart-header">
<h3>{parameter.label} {unit.label}</h3>
......@@ -227,7 +230,7 @@ class StationInfo extends React.Component {
</div> : null
}
{ stationMeta && !data ? <em>Geen data...</em> : null }
{ stationMeta && data.length === 0 ? <em>{ texts.nodata }</em> : null }
</div>
)
}
......
......@@ -45,6 +45,7 @@ export const removeFromArray = (array, value) => {
export const addMissingHours = (data) => {
if(!data[0]) return data
const dataStart = new Date(data[0].timestamp).getTime()
//const dataEnd = new Date(data[data.length-1].timestamp).getTime()
......
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