Exclude data for future dates
This commit is contained in:
@@ -64,9 +64,9 @@ 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
|
||||||
})
|
})
|
||||||
@@ -76,7 +76,9 @@ export default class CycleChart extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
determineCurvePoints() {
|
determineCurvePoints() {
|
||||||
return temperatureDaysSortedByDate.map(cycleDay => {
|
return temperatureDaysSortedByDate
|
||||||
|
.filter(cycleDayIsNotInTheFuture())
|
||||||
|
.map(cycleDay => {
|
||||||
const match = this.xAxisTicks.find(tick => tick.label === cycleDay.date)
|
const match = this.xAxisTicks.find(tick => tick.label === cycleDay.date)
|
||||||
const x = match.rightOffset + columnWidth / 2
|
const x = match.rightOffset + columnWidth / 2
|
||||||
const y = normalizeToScale(cycleDay.temperature.value)
|
const y = normalizeToScale(cycleDay.temperature.value)
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user