Exclude data for future dates
This commit is contained in:
@@ -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() {
|
||||||
@@ -154,4 +156,12 @@ function normalizeToScale(temp) {
|
|||||||
const valueRelativeToScale = (temperatureScale.high - temp) / (temperatureScale.high - temperatureScale.low)
|
const valueRelativeToScale = (temperatureScale.high - temp) / (temperatureScale.high - temperatureScale.low)
|
||||||
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