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
c54581d6
Commit
c54581d6
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Introduce symptom row (WIP)
parent
2471b92e
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
components/chart/chart.js
+16
-6
16 additions, 6 deletions
components/chart/chart.js
components/chart/day-column.js
+24
-29
24 additions, 29 deletions
components/chart/day-column.js
components/chart/y-axis.js
+20
-13
20 additions, 13 deletions
components/chart/y-axis.js
config.js
+4
-2
4 additions, 2 deletions
config.js
with
64 additions
and
50 deletions
components/chart/chart.js
+
16
−
6
View file @
c54581d6
...
...
@@ -8,6 +8,7 @@ import DayColumn from './day-column'
import
{
getCycleDay
,
cycleDaysSortedByDate
,
getAmountOfCycleDays
}
from
'
../../db
'
import
styles
from
'
./styles
'
import
{
scaleObservable
}
from
'
../../local-storage
'
import
config
from
'
../../config
'
export
default
class
CycleChart
extends
Component
{
constructor
(
props
)
{
...
...
@@ -70,9 +71,10 @@ export default class CycleChart extends Component {
},
{})
const
temp
=
symptoms
.
temperature
const
columnHeight
=
this
.
state
.
chartHeight
*
config
.
columnHeightPercentage
return
{
dateString
,
y
:
temp
?
normalizeToScale
(
temp
,
this
.
state
.
chart
Height
)
:
null
,
y
:
temp
?
normalizeToScale
(
temp
,
column
Height
)
:
null
,
...
symptoms
,
...
getFhmAndLtlInfo
(
dateString
,
temp
)
}
...
...
@@ -85,6 +87,12 @@ export default class CycleChart extends Component {
}
render
()
{
let
columnHeight
let
symptomRowHeight
if
(
this
.
state
.
chartHeight
)
{
columnHeight
=
this
.
state
.
chartHeight
*
config
.
columnHeightPercentage
symptomRowHeight
=
this
.
state
.
chartHeight
*
config
.
symptomRowHeightPercentage
}
return
(
<
View
onLayout
=
{
this
.
onLayout
}
...
...
@@ -93,12 +101,15 @@ export default class CycleChart extends Component {
{
!
this
.
state
.
chartHeight
&&
<
Text
>
Loading
...
<
/Text>
}
{
this
.
state
.
chartHeight
&&
<
View
style
=
{[
styles
.
yAxis
,
{
height
:
this
.
state
.
chartHeight
}]}
style
=
{[
styles
.
yAxis
,
{
height
:
columnHeight
,
marginTop
:
symptomRowHeight
}]}
>
{
makeYAxisLabels
(
this
.
state
.
chart
Height
)}
{
makeYAxisLabels
(
column
Height
)}
<
/View>
}
{
this
.
state
.
chartHeight
&&
makeHorizontalGrid
(
this
.
state
.
chart
Height
)}
{
this
.
state
.
chartHeight
&&
makeHorizontalGrid
(
columnHeight
,
symptomRow
Height
)}
{
this
.
state
.
chartHeight
&&
<
FlatList
...
...
@@ -110,8 +121,7 @@ export default class CycleChart extends Component {
keyExtractor
=
{
item
=>
item
.
dateString
}
initialNumToRender
=
{
15
}
maxToRenderPerBatch
=
{
5
}
>
<
/FlatList
>
/
>
}
<
/View
>
)
...
...
This diff is collapsed.
Click to expand it.
components/chart/day-column.js
+
24
−
29
View file @
c54581d6
...
...
@@ -34,36 +34,11 @@ export default class DayColumn extends Component {
rightY
,
rightTemperatureExclude
,
leftY
,
leftTemperatureExclude
leftTemperatureExclude
,
chartHeight
}
=
this
.
props
const
columnElements
=
[]
if
(
typeof
bleeding
===
'
number
'
)
{
columnElements
.
push
(
<
Icon
name
=
'
drop
'
position
=
'
absolute
'
size
=
{
18
}
color
=
'
#900
'
style
=
{{
marginTop
:
10
,
marginLeft
:
3
}}
key
=
'
bleeding
'
/>
)
}
if
(
typeof
mucus
===
'
number
'
)
{
const
mucusIcon
=
(
<
View
position
=
'
absolute
'
top
=
{
40
}
left
=
{
config
.
columnMiddle
-
styles
.
mucusIcon
.
width
/
2
}
{...
styles
.
mucusIcon
}
backgroundColor
=
{
styles
.
mucusIconShades
[
mucus
]}
key
=
'
mucus
'
/>
)
columnElements
.
push
(
mucusIcon
)
}
if
(
drawFhmLine
)
{
const
fhmLine
=
(
<
View
...
...
@@ -114,8 +89,9 @@ export default class DayColumn extends Component {
<
/Text
>
)
const
columnHeight
=
this
.
props
.
chartHeight
*
config
.
columnHeightPercentage
const
xAxisHeight
=
this
.
props
.
chartHeight
*
config
.
xAxisHeightPercentage
const
columnHeight
=
chartHeight
*
config
.
columnHeightPercentage
const
xAxisHeight
=
chartHeight
*
config
.
xAxisHeightPercentage
const
symptomHeight
=
chartHeight
*
config
.
symptomRowHeightPercentage
const
column
=
React
.
createElement
(
TouchableOpacity
,
...
...
@@ -132,7 +108,26 @@ export default class DayColumn extends Component {
return
(
<
View
>
<
View
style
=
{{
height
:
symptomHeight
}}
>
{
typeof
mucus
===
'
number
'
&&
<
View
{...
styles
.
mucusIcon
}
backgroundColor
=
{
styles
.
mucusIconShades
[
mucus
]}
key
=
'
mucus
'
/>
}
{
typeof
bleeding
===
'
number
'
&&
<
Icon
name
=
'
drop
'
size
=
{
18
}
color
=
'
#900
'
key
=
'
bleeding
'
/>
}
<
/View
>
{
column
}
<
View
style
=
{{
height
:
xAxisHeight
}}
>
{
cycleDayLabel
}
{
dateLabel
}
...
...
This diff is collapsed.
Click to expand it.
components/chart/y-axis.js
+
20
−
13
View file @
c54581d6
...
...
@@ -4,15 +4,16 @@ import config from '../../config'
import
styles
from
'
./styles
'
import
{
scaleObservable
}
from
'
../../local-storage
'
export
function
makeYAxisLabels
(
c
hart
Height
)
{
export
function
makeYAxisLabels
(
c
olumn
Height
)
{
const
units
=
config
.
temperatureScale
.
units
const
scaleMax
=
scaleObservable
.
value
.
max
const
style
=
styles
.
yAxisLabel
return
getTickPositions
(
c
hart
Height
).
map
((
y
,
i
)
=>
{
return
getTickPositions
(
c
olumn
Height
).
map
((
y
,
i
)
=>
{
// this eyeballing is sadly necessary because RN does not
// support percentage values for transforms, which we'd need
// to reliably place the label vertically centered to the grid
if
(
scaleMax
-
i
*
units
===
37
)
console
.
log
(
y
)
return
(
<
Text
style
=
{[
style
,
{
top
:
y
-
8
}]}
...
...
@@ -23,11 +24,11 @@ export function makeYAxisLabels(chartHeight) {
})
}
export
function
makeHorizontalGrid
(
c
hart
Height
)
{
return
getTickPositions
(
c
hart
Height
).
map
(
tick
=>
{
export
function
makeHorizontalGrid
(
c
olumnHeight
,
symptomRow
Height
)
{
return
getTickPositions
(
c
olumn
Height
).
map
(
tick
=>
{
return
(
<
View
top
=
{
tick
}
top
=
{
tick
+
symptomRowHeight
}
{...
styles
.
horizontalGrid
}
key
=
{
tick
}
/
>
...
...
@@ -35,25 +36,31 @@ export function makeHorizontalGrid(chartHeight) {
})
}
function
getTickPositions
(
c
hart
Height
)
{
function
getTickPositions
(
c
olumn
Height
)
{
const
units
=
config
.
temperatureScale
.
units
const
scaleMin
=
scaleObservable
.
value
.
min
const
scaleMax
=
scaleObservable
.
value
.
max
const
numberOfTicks
=
(
scaleMax
-
scaleMin
)
*
(
1
/
units
)
+
1
const
columnHeight
=
chartHeight
*
config
.
columnHeightPercentage
const
tickDistance
=
columnHeight
/
numberOfTicks
const
tickDistance
=
1
/
(
numberOfTicks
-
1
)
const
tickPositions
=
[]
const
margin
=
tickDistance
/
2
for
(
let
i
=
0
;
i
<
numberOfTicks
;
i
++
)
{
tickPositions
.
push
(
tickDistance
*
i
+
margin
)
const
position
=
getAbsoluteValue
(
tickDistance
*
i
,
columnHeight
)
tickPositions
.
push
(
position
)
}
return
tickPositions
}
export
function
normalizeToScale
(
temp
,
c
hart
Height
)
{
export
function
normalizeToScale
(
temp
,
c
olumn
Height
)
{
const
scale
=
scaleObservable
.
value
const
valueRelativeToScale
=
(
scale
.
max
-
temp
)
/
(
scale
.
max
-
scale
.
min
)
const
scaleHeight
=
chartHeight
*
config
.
columnHeightPercentage
return
scaleHeight
*
valueRelativeToScale
return
getAbsoluteValue
(
valueRelativeToScale
,
columnHeight
)
}
function
getAbsoluteValue
(
relative
,
columnHeight
)
{
// we add some height to have some breathing room
const
verticalPadding
=
columnHeight
*
config
.
temperatureScale
.
verticalPadding
const
scaleHeight
=
columnHeight
-
verticalPadding
return
scaleHeight
*
relative
+
verticalPadding
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
config.js
+
4
−
2
View file @
c54581d6
const
config
=
{
columnWidth
:
25
,
columnHeightPercentage
:
0.
92
,
columnHeightPercentage
:
0.
84
,
xAxisHeightPercentage
:
0.08
,
symptomRowHeightPercentage
:
0.08
,
temperatureScale
:
{
defaultLow
:
35
,
defaultHigh
:
38
,
min
:
34
,
max
:
40
,
units
:
0.1
units
:
0.1
,
verticalPadding
:
0.03
}
}
...
...
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