Skip to content
Snippets Groups Projects
Commit 3d12e5e4 authored by Julia Friesel's avatar Julia Friesel
Browse files

try doing the math

parent 542394df
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ const config = { ...@@ -5,7 +5,7 @@ const config = {
low: 35, low: 35,
high: 40 high: 40
}, },
xAxisRangeInDays: 50 xAxisRangeInDays: 1000
} }
const margin = 3 const margin = 3
......
...@@ -9,7 +9,7 @@ import { getOrCreateCycleDay } from '../../db' ...@@ -9,7 +9,7 @@ import { getOrCreateCycleDay } from '../../db'
import cycleModule from '../../lib/cycle' import cycleModule from '../../lib/cycle'
import setUpFertilityStatusFunc from './nfp-lines' import setUpFertilityStatusFunc from './nfp-lines'
import { horizontalGrid } from './y-axis' import { horizontalGrid } from './y-axis'
import slowlog from 'react-native-slowlog' //import slowlog from 'react-native-slowlog'
const getCycleDayNumber = cycleModule().getCycleDayNumber const getCycleDayNumber = cycleModule().getCycleDayNumber
const label = styles.column.label const label = styles.column.label
...@@ -18,7 +18,7 @@ const getFhmAndLtlInfo = setUpFertilityStatusFunc() ...@@ -18,7 +18,7 @@ const getFhmAndLtlInfo = setUpFertilityStatusFunc()
export default class DayColumn extends Component { export default class DayColumn extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
slowlog(this, /.*/, {threshold: 30}) //slowlog(this, /.*/, {threshold: 30})
} }
makeDayColumn(data, index) { makeDayColumn(data, index) {
const { const {
...@@ -68,8 +68,6 @@ export default class DayColumn extends Component { ...@@ -68,8 +68,6 @@ export default class DayColumn extends Component {
// /> : null} // /> : null}
// />) // />)
// onPress: () => this.passDateToDayView(dateString),
// <Path {...styles.bleedingIcon} // <Path {...styles.bleedingIcon}
// d="M15 3 // d="M15 3
// Q16.5 6.8 25 18 // Q16.5 6.8 25 18
...@@ -87,7 +85,7 @@ export default class DayColumn extends Component { ...@@ -87,7 +85,7 @@ export default class DayColumn extends Component {
// /> : null} // /> : null}
if (y) { if (y) {
columnElements.push(this.drawDotAndLines(y, temperatureExclude, index)) columnElements.push(...this.drawDotAndLine(y, temperatureExclude, index))
} }
// {cycleDay && cycleDay.mucus ? // {cycleDay && cycleDay.mucus ?
// <Circle // <Circle
...@@ -114,55 +112,59 @@ export default class DayColumn extends Component { ...@@ -114,55 +112,59 @@ export default class DayColumn extends Component {
) )
} }
drawDotAndLines(currY, exclude) { drawDotAndLine(currY, exclude) {
/* <View
width='150%'
borderStyle = 'solid'
borderColor = 'red'
borderWidth = {1}
position = 'absolute'
top={200}
style={{
transform: [{rotateZ: '30deg'}]
}}
/>
) */
let lineToRight let lineToRight
let lineToLeft let lineToLeft
/* function makeLine(otherColY, x, excludeLine) { function makeLine(leftY, rightY, leftX, excludeLine) {
const middleY = ((otherColY - currY) / 2) + currY const heightDiff = leftY - rightY
const target = [x, middleY] const angle = Math.atan2(config.columnWidth, heightDiff)
const lineStyle = excludeLine ? styles.curveExcluded : styles.curve const lineStyle = excludeLine ? styles.curveExcluded : styles.curve
// hypotenuse
return <Line const h = (config.columnWidth / 2) / Math.cos(angle)
x1={config.columnMiddle} const neededDiff = Math.sin(Math.PI - (angle + Math.PI / 2)) * (h / 2)
y1={currY} const projectedX = leftX - ((h / 2) - neededDiff)
x2={target[0]} console.log(leftX)
y2={target[1]} console.log(projectedX)
return (<View
width={h}
position = 'absolute'
top={(leftY + rightY) / 2}
left={projectedX}
style={{
// the rotation by default rotates from the middle of the line,
// but we want the transform origin to be at its beginning
// react native doesn't have transformOrigin, so we do this manually
transform: [
{rotateZ: `${angle}rad`}
],
}}
{...lineStyle} {...lineStyle}
/> />)
} */
/* if (this.props.rightY) {
const excludedLine = this.props.rightTemperatureExclude || exclude
lineToRight = makeLine(this.props.rightY, config.columnWidth, excludedLine)
} }
if (this.props.leftY) { if (this.props.leftY) {
const middleY = ((this.props.leftY - currY) / 2) + currY
const excludedLine = this.props.leftTemperatureExclude || exclude const excludedLine = this.props.leftTemperatureExclude || exclude
lineToLeft = makeLine(this.props.leftY, 0, excludedLine) lineToLeft = makeLine(middleY, currY, 0, excludedLine)
} */ }
if (this.props.rightY) {
const middleY = ((currY - this.props.rightY) / 2) + this.props.rightY
const excludedLine = this.props.rightTemperatureExclude || exclude
lineToRight = makeLine(currY, middleY, config.columnMiddle, excludedLine)
}
const dotStyle = exclude ? styles.curveDotsExcluded : styles.curveDots const dotStyle = exclude ? styles.curveDotsExcluded : styles.curveDots
/* return (<G> const dot = (
{lineToRight} <View
{lineToLeft} position='absolute'
<Circle top={currY - (dotStyle.height / 2)}
cx={config.columnMiddle} left={config.columnMiddle - (dotStyle.width / 2)}
cy={currY} style={dotStyle}
{...dotStyle}
/> />
</G>) */ )
return [lineToLeft, lineToRight, dot]
} }
passDateToDayView(dateString) { passDateToDayView(dateString) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment