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() {
return bleedingDaysSortedByDate.map(day => {
// TODO handle no bleeding days, same for curve
// TODO exclude future bleeding days (??)
const match = this.xAxisTicks.find(tick => {
return tick.label === day.date
return bleedingDaysSortedByDate
.filter(cycleDayIsNotInTheFuture())
.map(day => {
const match = this.xAxisTicks.find(tick => {
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() {
return temperatureDaysSortedByDate.map(cycleDay => {
const match = this.xAxisTicks.find(tick => tick.label === cycleDay.date)
const x = match.rightOffset + columnWidth / 2
const y = normalizeToScale(cycleDay.temperature.value)
return [x, y].join()
}).join(' ')
return temperatureDaysSortedByDate
.filter(cycleDayIsNotInTheFuture())
.map(cycleDay => {
const match = this.xAxisTicks.find(tick => tick.label === cycleDay.date)
const x = match.rightOffset + columnWidth / 2
const y = normalizeToScale(cycleDay.temperature.value)
return [x, y].join()
}).join(' ')
}
componentDidMount() {
@@ -155,3 +157,11 @@ function normalizeToScale(temp) {
const scaleHeight = bottom - top
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)
}
}