Exclude data for future dates

This commit is contained in:
Julia Friesel
2018-06-20 16:02:08 +02:00
parent e85e1c0de9
commit 26d6e7f4a1
+24 -14
View File
@@ -64,24 +64,26 @@ export default class CycleChart extends Component {
} }
placeBleedingSymbolsOnColumns() { placeBleedingSymbolsOnColumns() {
return bleedingDaysSortedByDate.map(day => { return bleedingDaysSortedByDate
// TODO handle no bleeding days, same for curve .filter(cycleDayIsNotInTheFuture())
// TODO exclude future bleeding days (??) .map(day => {
const match = this.xAxisTicks.find(tick => { const match = this.xAxisTicks.find(tick => {
return tick.label === day.date return tick.label === day.date
})
const x = match.rightOffset + columnWidth / 2
return (<Circle key={day.date} cx={x} cy="50" r="7" fill="red" />)
}) })
const x = match.rightOffset + columnWidth / 2
return (<Circle key={day.date} cx={x} cy="50" r="7" fill="red" />)
})
} }
determineCurvePoints() { determineCurvePoints() {
return temperatureDaysSortedByDate.map(cycleDay => { return temperatureDaysSortedByDate
const match = this.xAxisTicks.find(tick => tick.label === cycleDay.date) .filter(cycleDayIsNotInTheFuture())
const x = match.rightOffset + columnWidth / 2 .map(cycleDay => {
const y = normalizeToScale(cycleDay.temperature.value) const match = this.xAxisTicks.find(tick => tick.label === cycleDay.date)
return [x, y].join() const x = match.rightOffset + columnWidth / 2
}).join(' ') const y = normalizeToScale(cycleDay.temperature.value)
return [x, y].join()
}).join(' ')
} }
componentDidMount() { componentDidMount() {
@@ -155,3 +157,11 @@ function normalizeToScale(temp) {
const scaleHeight = bottom - top const scaleHeight = bottom - top
return scaleHeight * valueRelativeToScale return scaleHeight * valueRelativeToScale
} }
function cycleDayIsNotInTheFuture() {
const today = LocalDate.now()
return function (cycleDay) {
const cycleDayLocalDate = LocalDate.parse(cycleDay.date)
return cycleDayLocalDate.isBefore(today) || cycleDayLocalDate.isEqual(today)
}
}