diff --git a/components/chart/chart.js b/components/chart/chart.js
index 79bea87..7a90b87 100644
--- a/components/chart/chart.js
+++ b/components/chart/chart.js
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
-import { Text as ReactNativeText, View, FlatList, ScrollView } from 'react-native'
+import { Text as ReactNativeText, View, FlatList } from 'react-native'
import range from 'date-range'
import Svg,{
G,
@@ -45,21 +45,36 @@ export default class CycleChart extends Component {
this.props.navigation.navigate('cycleDay', { cycleDay })
}
- placeHorizontalGrid() {
- return yAxis.tickPositions.map(tick => {
- return (
-
- )
- })
+ render() {
+ return (
+
+ {yAxis.labels}
+ {
+ const cols = this.state.columns
+ return (
+ 0 ? cols[index - 1] : undefined }
+ leftNeighbor = {index < cols.length - 1 ? cols[index + 1] : undefined }
+ />
+ )
+ }}
+ keyExtractor={item => item.dateString}
+ initialNumToRender={20}
+ >
+
+
+ )
}
+}
+class DayColumn extends Component {
makeDayColumn({ dateString, cycleDay, y }, index) {
const cycleDayNumber = getCycleDayNumber(dateString)
const label = styles.column.label
@@ -116,16 +131,15 @@ export default class CycleChart extends Component {
/> : null}
{y ?
- this.drawDotAndLines(y, cycleDay.temperature.exclude, index)
+ this.drawDotAndLines(y, cycleDay.temperature.exclude)
: null}
)
}
- drawDotAndLines(currY, exclude, index) {
+ drawDotAndLines(currY, exclude) {
let lineToRight
let lineToLeft
- const cols = this.state.columns
function makeLine(otherColY, x, excludeLine) {
const middleY = ((otherColY - currY) / 2) + currY
@@ -141,18 +155,18 @@ export default class CycleChart extends Component {
/>
}
- const thereIsADotToTheRight = index > 0 && cols[index - 1].y
- const thereIsADotToTheLeft = index < cols.length - 1 && cols[index + 1].y
+ const thereIsADotToTheRight = this.props.rightNeighbor && this.props.rightNeighbor.y
+ const thereIsADotToTheLeft = this.props.leftNeighbor && this.props.leftNeighbor.y
if (thereIsADotToTheRight) {
- const otherDot = cols[index - 1]
- const excludedLine = otherDot.cycleDay.temperature.exclude || exclude
- lineToRight = makeLine(otherDot.y, config.columnWidth, excludedLine)
+ const neighbor = this.props.rightNeighbor
+ const excludedLine = neighbor.cycleDay.temperature.exclude || exclude
+ lineToRight = makeLine(neighbor.y, config.columnWidth, excludedLine)
}
if (thereIsADotToTheLeft) {
- const otherDot = cols[index + 1]
- const excludedLine = otherDot.cycleDay.temperature.exclude || exclude
- lineToLeft = makeLine(otherDot.y, 0, excludedLine)
+ const neighbor = this.props.leftNeighbor
+ const excludedLine = neighbor.cycleDay.temperature.exclude || exclude
+ lineToLeft = makeLine(neighbor.y, 0, excludedLine)
}
const dotStyle = exclude ? styles.curveDotsExcluded : styles.curveDots
@@ -167,26 +181,26 @@ export default class CycleChart extends Component {
)
}
+ placeHorizontalGrid() {
+ return yAxis.tickPositions.map(tick => {
+ return (
+
+ )
+ })
+ }
+
render() {
return (
-
- {yAxis.labels}
- {
- return (
-
- )
- }}
- keyExtractor={item => item.dateString}
- >
-
-
+
)
}
}