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
9938cc48
Commit
9938cc48
authored
7 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Display cycle day number along with date
parent
f87f676a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/chart.js
+30
-21
30 additions, 21 deletions
components/chart.js
with
30 additions
and
21 deletions
components/chart.js
+
30
−
21
View file @
9938cc48
...
@@ -10,16 +10,20 @@ import Svg,{
...
@@ -10,16 +10,20 @@ import Svg,{
}
from
'
react-native-svg
'
}
from
'
react-native-svg
'
import
{
LocalDate
}
from
'
js-joda
'
import
{
LocalDate
}
from
'
js-joda
'
import
{
getCycleDay
,
getOrCreateCycleDay
,
cycleDaysSortedByDate
}
from
'
../db
'
import
{
getCycleDay
,
getOrCreateCycleDay
,
cycleDaysSortedByDate
}
from
'
../db
'
import
getCycleDayNumberModule
from
'
../get-cycle-day-number
'
const
right
=
600
const
getCycleDayNumber
=
getCycleDayNumberModule
()
const
top
=
10
const
bottom
=
350
const
chartLength
=
350
const
columnWidth
=
30
const
columnWidth
=
30
const
middle
=
columnWidth
/
2
const
middle
=
columnWidth
/
2
const
dateRow
=
{
const
xAxis
=
{
height
:
30
,
top
:
chartLength
-
15
,
width
:
right
margin
:
3
}
}
const
dateRowY
=
xAxis
.
top
-
xAxis
.
margin
const
cycleDayNumberRowY
=
chartLength
-
xAxis
.
margin
const
temperatureScale
=
{
const
temperatureScale
=
{
low
:
33
,
low
:
33
,
high
:
40
high
:
40
...
@@ -53,24 +57,29 @@ export default class CycleChart extends Component {
...
@@ -53,24 +57,29 @@ export default class CycleChart extends Component {
this
.
props
.
navigation
.
navigate
(
'
cycleDay
'
,
{
cycleDay
})
this
.
props
.
navigation
.
navigate
(
'
cycleDay
'
,
{
cycleDay
})
}
}
makeDayColumn
({
label
,
cycleDay
,
y
},
index
)
{
makeDayColumn
({
dateString
,
cycleDay
,
y
},
index
)
{
const
cycleDayNumber
=
getCycleDayNumber
(
dateString
)
const
labelProps
=
{
stroke
:
"
grey
"
,
fontSize
:
"
10
"
,
x
:
0
,
}
const
dateLabel
=
dateString
.
split
(
'
-
'
).
slice
(
1
).
join
(
'
-
'
)
return
(
return
(
<
G
key
=
{
label
}
onPress
=
{()
=>
this
.
passDateToDayView
(
label
)}
>
<
G
key
=
{
dateString
}
onPress
=
{()
=>
this
.
passDateToDayView
(
dateString
)}
>
<
Rect
<
Rect
x
=
{
0
}
x
=
{
0
}
y
=
{
top
}
y
=
{
0
}
width
=
{
columnWidth
}
width
=
{
columnWidth
}
height
=
{
bottom
-
top
-
dateRow
.
height
}
height
=
{
chartLength
}
fill
=
"
lightgrey
"
fill
=
"
lightgrey
"
strokeWidth
=
"
1
"
strokeWidth
=
"
1
"
stroke
=
"
grey
"
stroke
=
"
grey
"
/>
/>
<
Text
<
Text
{...
labelProps
}
y
=
{
cycleDayNumberRowY
}
>
{
cycleDayNumber
}
<
/Text
>
stroke
=
"
grey
"
<
Text
{...
labelProps
}
y
=
{
dateRowY
}
>
{
dateLabel
}
<
/Text
>
fontSize
=
"
10
"
x
=
{
0
}
y
=
{
bottom
-
top
-
dateRow
.
height
}
>
{
label
.
split
(
'
-
'
)[
2
]}
<
/Text
>
{
cycleDay
&&
cycleDay
.
bleeding
?
<
Circle
cx
=
{
middle
}
cy
=
"
50
"
r
=
"
7
"
fill
=
"
red
"
/>
:
null
}
{
cycleDay
&&
cycleDay
.
bleeding
?
<
Circle
cx
=
{
middle
}
cy
=
"
50
"
r
=
"
7
"
fill
=
"
red
"
/>
:
null
}
...
@@ -127,7 +136,7 @@ export default class CycleChart extends Component {
...
@@ -127,7 +136,7 @@ export default class CycleChart extends Component {
data
=
{
this
.
state
.
columns
}
data
=
{
this
.
state
.
columns
}
renderItem
=
{({
item
,
index
})
=>
{
renderItem
=
{({
item
,
index
})
=>
{
return
(
return
(
<
Svg
width
=
{
columnWidth
}
height
=
{
bottom
}
>
<
Svg
width
=
{
columnWidth
}
height
=
{
chartLength
}
>
{
this
.
makeDayColumn
(
item
,
index
)}
{
this
.
makeDayColumn
(
item
,
index
)}
<
/Svg
>
<
/Svg
>
)
)
...
@@ -148,11 +157,11 @@ function makeColumnInfo(n) {
...
@@ -148,11 +157,11 @@ function makeColumnInfo(n) {
).
toString
()
).
toString
()
})
})
return
xAxisDates
.
map
(
date
s
tring
=>
{
return
xAxisDates
.
map
(
date
S
tring
=>
{
const
cycleDay
=
getCycleDay
(
date
s
tring
)
const
cycleDay
=
getCycleDay
(
date
S
tring
)
const
temp
=
cycleDay
&&
cycleDay
.
temperature
&&
cycleDay
.
temperature
.
value
const
temp
=
cycleDay
&&
cycleDay
.
temperature
&&
cycleDay
.
temperature
.
value
return
{
return
{
label
:
date
s
tring
,
date
S
tring
,
cycleDay
,
cycleDay
,
y
:
temp
?
normalizeToScale
(
temp
)
:
null
y
:
temp
?
normalizeToScale
(
temp
)
:
null
}
}
...
@@ -169,6 +178,6 @@ function getPreviousDays(n) {
...
@@ -169,6 +178,6 @@ function getPreviousDays(n) {
function
normalizeToScale
(
temp
)
{
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
=
chartLength
return
scaleHeight
*
valueRelativeToScale
return
scaleHeight
*
valueRelativeToScale
}
}
\ No newline at end of file
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