Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
bb003c97
Commit
bb003c97
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Determine heights of chart areas in chart and pass them to children
parent
51bbaa9f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
components/chart/chart.js
+53
-36
53 additions, 36 deletions
components/chart/chart.js
components/chart/day-column.js
+109
-70
109 additions, 70 deletions
components/chart/day-column.js
components/chart/styles.js
+0
-2
0 additions, 2 deletions
components/chart/styles.js
config.js
+1
-2
1 addition, 2 deletions
config.js
with
163 additions
and
110 deletions
components/chart/chart.js
+
53
−
36
View file @
bb003c97
...
@@ -21,7 +21,10 @@ export default class CycleChart extends Component {
...
@@ -21,7 +21,10 @@ export default class CycleChart extends Component {
{...
item
}
{...
item
}
index
=
{
index
}
index
=
{
index
}
navigate
=
{
this
.
props
.
navigate
}
navigate
=
{
this
.
props
.
navigate
}
symptomHeight
=
{
this
.
symptomHeight
}
columnHeight
=
{
this
.
columnHeight
}
chartHeight
=
{
this
.
state
.
chartHeight
}
chartHeight
=
{
this
.
state
.
chartHeight
}
symptomRowSymptoms
=
{
this
.
symptomRowSymptoms
}
/
>
/
>
)
)
}
}
...
@@ -33,7 +36,34 @@ export default class CycleChart extends Component {
...
@@ -33,7 +36,34 @@ export default class CycleChart extends Component {
const
height
=
nativeEvent
.
layout
.
height
const
height
=
nativeEvent
.
layout
.
height
this
.
setState
({
chartHeight
:
height
})
this
.
setState
({
chartHeight
:
height
})
this
.
reCalculateChartInfo
=
()
=>
{
this
.
reCalculateChartInfo
=
()
=>
{
this
.
setState
({
columns
:
this
.
makeColumnInfo
(
nfpLines
())
})
// how many symptoms need to be displayed on the chart's upper symptom row?
this
.
symptomRowSymptoms
=
[
'
bleeding
'
,
'
mucus
'
,
'
cervix
'
,
'
sex
'
,
'
desire
'
,
'
pain
'
,
'
note
'
].
filter
((
symptomName
)
=>
{
return
this
.
cycleDaysSortedByDate
.
some
(
cycleDay
=>
{
return
cycleDay
[
symptomName
]
})
})
this
.
xAxisHeight
=
this
.
state
.
chartHeight
*
config
.
xAxisHeightPercentage
const
remainingHeight
=
this
.
state
.
chartHeight
-
this
.
xAxisHeight
this
.
symptomHeight
=
config
.
symptomHeightPercentage
*
remainingHeight
this
.
symptomRowHeight
=
this
.
symptomRowSymptoms
.
length
*
this
.
symptomHeight
this
.
columnHeight
=
remainingHeight
-
this
.
symptomRowHeight
const
chartSymptoms
=
[...
this
.
symptomRowSymptoms
]
if
(
this
.
cycleDaysSortedByDate
.
some
(
day
=>
day
.
temperature
))
{
chartSymptoms
.
push
(
'
temperature
'
)
}
const
columnData
=
this
.
makeColumnInfo
(
nfpLines
(),
chartSymptoms
)
this
.
setState
({
columns
:
columnData
})
}
}
this
.
cycleDaysSortedByDate
.
addListener
(
this
.
reCalculateChartInfo
)
this
.
cycleDaysSortedByDate
.
addListener
(
this
.
reCalculateChartInfo
)
...
@@ -45,7 +75,7 @@ export default class CycleChart extends Component {
...
@@ -45,7 +75,7 @@ export default class CycleChart extends Component {
this
.
removeObvListener
()
this
.
removeObvListener
()
}
}
makeColumnInfo
(
getFhmAndLtlInfo
)
{
makeColumnInfo
(
getFhmAndLtlInfo
,
chartSymptoms
)
{
let
amountOfCycleDays
=
getAmountOfCycleDays
()
let
amountOfCycleDays
=
getAmountOfCycleDays
()
// if there's not much data yet, we want to show at least 30 days on the chart
// if there's not much data yet, we want to show at least 30 days on the chart
if
(
amountOfCycleDays
<
30
)
{
if
(
amountOfCycleDays
<
30
)
{
...
@@ -63,21 +93,11 @@ export default class CycleChart extends Component {
...
@@ -63,21 +93,11 @@ export default class CycleChart extends Component {
).
toString
()
).
toString
()
})
})
const
chartSymptoms
=
[
'
bleeding
'
,
'
temperature
'
,
'
mucus
'
,
'
cervix
'
,
'
sex
'
,
'
desire
'
,
'
pain
'
,
'
note
'
].
filter
((
symptomName
)
=>
{
return
this
.
cycleDaysSortedByDate
.
some
(
cycleDay
=>
cycleDay
[
symptomName
])
})
const
columns
=
xAxisDates
.
map
(
dateString
=>
{
const
columns
=
xAxisDates
.
map
(
dateString
=>
{
const
column
=
{
dateString
}
const
cycleDay
=
getCycleDay
(
dateString
)
const
cycleDay
=
getCycleDay
(
dateString
)
if
(
!
cycleDay
)
return
column
const
symptoms
=
chartSymptoms
.
reduce
((
acc
,
symptom
)
=>
{
const
symptoms
=
chartSymptoms
.
reduce
((
acc
,
symptom
)
=>
{
if
(
symptom
===
'
bleeding
'
||
if
(
symptom
===
'
bleeding
'
||
symptom
===
'
temperature
'
||
symptom
===
'
temperature
'
||
...
@@ -85,28 +105,29 @@ export default class CycleChart extends Component {
...
@@ -85,28 +105,29 @@ export default class CycleChart extends Component {
symptom
===
'
desire
'
||
symptom
===
'
desire
'
||
symptom
===
'
note
'
symptom
===
'
note
'
)
{
)
{
acc
[
symptom
]
=
cycleDay
&&
cycleDay
[
symptom
]
&&
cycleDay
[
symptom
].
value
acc
[
symptom
]
=
cycleDay
[
symptom
]
&&
cycleDay
[
symptom
].
value
}
else
if
(
symptom
===
'
cervix
'
)
{
}
else
if
(
symptom
===
'
cervix
'
)
{
acc
[
symptom
]
=
cycleDay
&&
cycleDay
[
'
cervix
'
]
&&
(
cycleDay
[
'
cervix
'
].
opening
+
cycleDay
[
'
cervix
'
].
firmness
)
acc
.
cervix
=
cycleDay
.
cervix
&&
(
cycleDay
.
cervix
.
opening
+
cycleDay
.
cervix
.
firmness
)
}
else
if
(
symptom
===
'
sex
'
)
{
}
else
if
(
symptom
===
'
sex
'
)
{
// solo = 1 + partner = 2
// solo = 1 + partner = 2
acc
[
symptom
]
=
cycleDay
&&
cycleDay
[
'
sex
'
]
&&
(
cycleDay
[
'
sex
'
]
.
solo
+
cycleDay
[
'
sex
'
]
.
partner
)
acc
.
sex
=
cycleDay
.
sex
&&
(
cycleDay
.
sex
.
solo
+
cycleDay
.
sex
.
partner
)
}
else
if
(
symptom
===
'
pain
'
)
{
}
else
if
(
symptom
===
'
pain
'
)
{
// is any pain documented?
// is any pain documented?
acc
[
symptom
]
=
cycleDay
&&
cycleDay
[
'
pain
'
]
&&
Object
.
values
(
cycleDay
[
'
pain
'
]).
some
(
x
=>
x
===
true
)
acc
.
pain
=
cycleDay
.
pain
&&
Object
.
values
(
cycleDay
.
pain
).
some
(
x
=>
x
===
true
)
}
}
acc
[
`
${
symptom
}
Exclude`
]
=
cycleDay
&&
cycleDay
[
symptom
]
&&
cycleDay
[
symptom
].
exclude
acc
[
`
${
symptom
}
Exclude`
]
=
cycleDay
[
symptom
]
&&
cycleDay
[
symptom
].
exclude
return
acc
return
acc
},
{})
},
{})
const
temp
=
symptoms
.
temperature
const
temp
=
symptoms
.
temperature
const
columnHeight
=
this
.
state
.
chartHeight
*
config
.
columnHeightPercentage
if
(
temp
)
{
return
{
column
.
y
=
normalizeToScale
(
temp
,
this
.
columnHeight
)
dateString
,
y
:
temp
?
normalizeToScale
(
temp
,
columnHeight
)
:
null
,
...
symptoms
,
...
getFhmAndLtlInfo
(
dateString
,
temp
,
columnHeight
)
}
}
const
fhmAndLtl
=
getFhmAndLtlInfo
(
dateString
,
temp
,
this
.
columnHeight
)
return
Object
.
assign
(
column
,
symptoms
,
fhmAndLtl
)
})
})
return
columns
.
map
((
col
,
i
)
=>
{
return
columns
.
map
((
col
,
i
)
=>
{
...
@@ -116,12 +137,6 @@ export default class CycleChart extends Component {
...
@@ -116,12 +137,6 @@ export default class CycleChart extends Component {
}
}
render
()
{
render
()
{
let
columnHeight
let
symptomRowHeight
if
(
this
.
state
.
chartHeight
)
{
columnHeight
=
this
.
state
.
chartHeight
*
config
.
columnHeightPercentage
symptomRowHeight
=
this
.
state
.
chartHeight
*
config
.
symptomRowHeightPercentage
}
return
(
return
(
<
View
<
View
onLayout
=
{
this
.
onLayout
}
onLayout
=
{
this
.
onLayout
}
...
@@ -136,14 +151,16 @@ export default class CycleChart extends Component {
...
@@ -136,14 +151,16 @@ export default class CycleChart extends Component {
{
this
.
state
.
chartHeight
&&
this
.
state
.
chartLoaded
&&
{
this
.
state
.
chartHeight
&&
this
.
state
.
chartLoaded
&&
<
View
<
View
style
=
{[
styles
.
yAxis
,
{
style
=
{[
styles
.
yAxis
,
{
height
:
columnHeight
,
height
:
this
.
columnHeight
,
marginTop
:
symptomRowHeight
marginTop
:
this
.
symptomRowHeight
}]}
}]}
>
>
{
makeYAxisLabels
(
columnHeight
)}
{
makeYAxisLabels
(
this
.
columnHeight
)}
<
/View>
}
<
/View>
}
{
this
.
state
.
chartHeight
&&
this
.
state
.
chartLoaded
&&
makeHorizontalGrid
(
columnHeight
,
symptomRowHeight
)}
{
this
.
state
.
chartHeight
&&
this
.
state
.
chartLoaded
&&
makeHorizontalGrid
(
this
.
columnHeight
,
this
.
symptomRowHeight
)
}
{
this
.
state
.
chartHeight
&&
{
this
.
state
.
chartHeight
&&
<
FlatList
<
FlatList
...
...
This diff is collapsed.
Click to expand it.
components/chart/day-column.js
+
109
−
70
View file @
bb003c97
...
@@ -37,12 +37,13 @@ export default class DayColumn extends Component {
...
@@ -37,12 +37,13 @@ export default class DayColumn extends Component {
rightTemperatureExclude
,
rightTemperatureExclude
,
leftY
,
leftY
,
leftTemperatureExclude
,
leftTemperatureExclude
,
chartHeight
columnHeight
,
symptomHeight
,
chartHeight
,
symptomRowSymptoms
,
xAxisHeight
}
=
this
.
props
}
=
this
.
props
const
columnHeight
=
chartHeight
*
config
.
columnHeightPercentage
const
xAxisHeight
=
chartHeight
*
config
.
xAxisHeightPercentage
const
symptomHeight
=
chartHeight
*
config
.
symptomRowHeightPercentage
const
columnElements
=
[]
const
columnElements
=
[]
...
@@ -108,77 +109,102 @@ export default class DayColumn extends Component {
...
@@ -108,77 +109,102 @@ export default class DayColumn extends Component {
<
/G
>
<
/G
>
)
)
const
symptomIconViews
=
{
bleeding
:
(
<
SymptomIconView
value
=
{
this
.
props
.
bleeding
}
symptomHeight
=
{
symptomHeight
}
key
=
'
bleeding
'
>
<
Icon
name
=
'
drop
'
size
=
{
12
}
color
=
{
styles
.
bleedingIconShades
[
this
.
props
.
bleeding
]}
/
>
<
/SymptomIconView
>
),
mucus
:
(
<
SymptomIconView
value
=
{
this
.
props
.
mucus
}
symptomHeight
=
{
symptomHeight
}
key
=
'
mucus
'
>
<
View
{...
styles
.
mucusIcon
}
backgroundColor
=
{
styles
.
mucusIconShades
[
this
.
props
.
mucus
]}
/
>
<
/SymptomIconView
>
),
cervix
:
(
<
SymptomIconView
value
=
{
this
.
props
.
cervix
}
symptomHeight
=
{
symptomHeight
}
key
=
'
cervix
'
>
<
View
{...
styles
.
mucusIcon
}
// cervix is sum of openess and firmness - fertile only when closed and hard (=0)
backgroundColor
=
{
this
.
props
.
cervix
>
0
?
'
blue
'
:
'
green
'
}
/
>
<
/SymptomIconView
>
),
sex
:
(
<
SymptomIconView
value
=
{
this
.
props
.
sex
}
symptomHeight
=
{
symptomHeight
}
key
=
'
sex
'
>
<
View
{...
styles
.
mucusIcon
}
backgroundColor
=
'
orange
'
/>
<
/SymptomIconView
>
),
desire
:
(
<
SymptomIconView
value
=
{
this
.
props
.
desire
}
symptomHeight
=
{
symptomHeight
}
key
=
'
desire
'
>
<
View
{...
styles
.
mucusIcon
}
backgroundColor
=
'
red
'
/>
<
/SymptomIconView
>
),
pain
:
(
<
SymptomIconView
value
=
{
this
.
props
.
pain
}
symptomHeight
=
{
symptomHeight
}
key
=
'
pain
'
>
<
View
{...
styles
.
mucusIcon
}
backgroundColor
=
'
blue
'
/>
<
/SymptomIconView
>
),
note
:
(
<
SymptomIconView
value
=
{
this
.
props
.
note
}
symptomHeight
=
{
symptomHeight
}
key
=
'
note
'
>
<
View
{...
styles
.
mucusIcon
}
backgroundColor
=
'
green
'
/>
<
/SymptomIconView
>
)
}
return
(
return
(
<
TouchableOpacity
<
TouchableOpacity
onPress
=
{()
=>
this
.
passDateToDayView
(
dateString
)}
onPress
=
{()
=>
this
.
passDateToDayView
(
dateString
)}
activeOpacity
=
{
1
}
activeOpacity
=
{
1
}
>
>
<
View
height
=
{
symptomHeight
}
>
<
View
>
<
View
style
=
{
styles
.
symptomRow
}
>
{
symptomRowSymptoms
.
map
(
symptomName
=>
symptomIconViews
[
symptomName
])}
{
typeof
this
.
props
.
bleeding
===
'
number
'
&&
<
Icon
name
=
'
drop
'
size
=
{
12
}
color
=
{
styles
.
bleedingIconShades
[
this
.
props
.
bleeding
]}
key
=
'
bleeding
'
/>
}
<
/View
>
<
View
style
=
{
styles
.
symptomRow
}
>
{
typeof
this
.
props
.
mucus
===
'
number
'
&&
<
View
{...
styles
.
mucusIcon
}
backgroundColor
=
{
styles
.
mucusIconShades
[
this
.
props
.
mucus
]}
key
=
'
mucus
'
/>
}
<
/View
>
<
View
style
=
{
styles
.
symptomRow
}
>
{
typeof
this
.
props
.
cervix
===
'
number
'
&&
<
View
{...
styles
.
mucusIcon
}
// cervix is sum of openess and firmness - fertile only when closed and hard (=0)
backgroundColor
=
{
this
.
props
.
cervix
>
0
?
'
blue
'
:
'
green
'
}
key
=
'
cervix
'
/>
}
<
/View
>
<
View
style
=
{
styles
.
symptomRow
}
>
{
typeof
this
.
props
.
sex
===
'
number
'
&&
<
View
{...
styles
.
mucusIcon
}
backgroundColor
=
'
orange
'
key
=
'
sex
'
/>
}
<
/View
>
<
View
style
=
{
styles
.
symptomRow
}
>
{
typeof
this
.
props
.
desire
===
'
number
'
&&
<
View
{...
styles
.
mucusIcon
}
backgroundColor
=
'
red
'
key
=
'
desire
'
/>
}
<
/View
>
<
View
style
=
{
styles
.
symptomRow
}
>
{
this
.
props
.
pain
&&
<
View
{...
styles
.
mucusIcon
}
backgroundColor
=
'
blue
'
key
=
'
pain
'
/>
}
<
/View
>
<
View
style
=
{
styles
.
symptomRow
}
>
{
this
.
props
.
note
&&
<
View
{...
styles
.
mucusIcon
}
backgroundColor
=
'
green
'
key
=
'
note
'
/>
}
<
/View
>
<
/View
>
<
/View
>
<
Svg
width
=
{
config
.
columnWidth
}
height
=
{
columnHeight
}
>
<
Svg
width
=
{
config
.
columnWidth
}
height
=
{
columnHeight
}
>
...
@@ -193,3 +219,16 @@ export default class DayColumn extends Component {
...
@@ -193,3 +219,16 @@ export default class DayColumn extends Component {
)
)
}
}
}
}
function
SymptomIconView
(
props
)
{
const
style
=
[
styles
.
symptomRow
,
{
height
:
props
.
symptomHeight
}]
return
(
<
View
style
=
{
style
}
>
{(
typeof
props
.
value
===
'
number
'
||
props
.
value
===
true
||
typeof
props
.
value
===
'
string
'
)
&&
props
.
children
}
<
/View
>
)
}
This diff is collapsed.
Click to expand it.
components/chart/styles.js
+
0
−
2
View file @
bb003c97
...
@@ -95,8 +95,6 @@ const styles = {
...
@@ -95,8 +95,6 @@ const styles = {
symptomRow
:
{
symptomRow
:
{
alignItems
:
'
center
'
,
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
,
justifyContent
:
'
center
'
,
width
:
'
100%
'
,
flex
:
1
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
config.js
+
1
−
2
View file @
bb003c97
const
config
=
{
const
config
=
{
columnWidth
:
25
,
columnWidth
:
25
,
columnHeightPercentage
:
0.62
,
xAxisHeightPercentage
:
0.08
,
xAxisHeightPercentage
:
0.08
,
symptom
Row
HeightPercentage
:
0.
3
0
,
symptomHeightPercentage
:
0.0
5
,
temperatureScale
:
{
temperatureScale
:
{
defaultLow
:
35
,
defaultLow
:
35
,
defaultHigh
:
38
,
defaultHigh
:
38
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment