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
cd1e689a
Commit
cd1e689a
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Get actual amount of cycle days to display
parent
0afaf8e2
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
+14
-7
14 additions, 7 deletions
components/chart/chart.js
components/chart/config.js
+1
-2
1 addition, 2 deletions
components/chart/config.js
components/chart/day-column.js
+0
-1
0 additions, 1 deletion
components/chart/day-column.js
db/index.js
+12
-2
12 additions, 2 deletions
db/index.js
with
27 additions
and
12 deletions
components/chart/chart.js
+
14
−
7
View file @
cd1e689a
...
@@ -4,9 +4,8 @@ import range from 'date-range'
...
@@ -4,9 +4,8 @@ import range from 'date-range'
import
{
LocalDate
}
from
'
js-joda
'
import
{
LocalDate
}
from
'
js-joda
'
import
{
yAxis
,
normalizeToScale
}
from
'
./y-axis
'
import
{
yAxis
,
normalizeToScale
}
from
'
./y-axis
'
import
DayColumn
from
'
./day-column
'
import
DayColumn
from
'
./day-column
'
import
{
getCycleDay
,
cycleDaysSortedByDate
}
from
'
../../db
'
import
{
getCycleDay
,
cycleDaysSortedByDate
,
getAmountOfCycleDays
}
from
'
../../db
'
import
styles
from
'
./styles
'
import
styles
from
'
./styles
'
import
config
from
'
./config
'
const
yAxisView
=
<
View
{...
styles
.
yAxis
}
>
{
yAxis
.
labels
}
<
/View
>
const
yAxisView
=
<
View
{...
styles
.
yAxis
}
>
{
yAxis
.
labels
}
<
/View
>
...
@@ -14,7 +13,7 @@ export default class CycleChart extends Component {
...
@@ -14,7 +13,7 @@ export default class CycleChart extends Component {
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
)
super
(
props
)
this
.
state
=
{
this
.
state
=
{
columns
:
makeColumnInfo
(
config
.
xAxisRangeInDays
)
columns
:
makeColumnInfo
()
,
}
}
this
.
renderColumn
=
({
item
,
index
})
=>
{
this
.
renderColumn
=
({
item
,
index
})
=>
{
return
(
return
(
...
@@ -29,7 +28,7 @@ export default class CycleChart extends Component {
...
@@ -29,7 +28,7 @@ export default class CycleChart extends Component {
this
.
reCalculateChartInfo
=
(
function
(
Chart
)
{
this
.
reCalculateChartInfo
=
(
function
(
Chart
)
{
return
function
()
{
return
function
()
{
Chart
.
setState
({
columns
:
makeColumnInfo
(
config
.
xAxisRangeInDays
)})
Chart
.
setState
({
columns
:
makeColumnInfo
()})
}
}
})(
this
)
})(
this
)
...
@@ -60,8 +59,16 @@ export default class CycleChart extends Component {
...
@@ -60,8 +59,16 @@ export default class CycleChart extends Component {
}
}
}
}
function
makeColumnInfo
(
n
)
{
function
makeColumnInfo
()
{
const
xAxisDates
=
getPreviousDays
(
n
).
map
(
jsDate
=>
{
let
amountOfCycleDays
=
getAmountOfCycleDays
()
// if there's not much data yet, we want to show at least 30 days on the chart
if
(
amountOfCycleDays
<
30
)
{
amountOfCycleDays
=
30
}
else
{
// we don't want the chart to end abruptly before the first data day
amountOfCycleDays
+=
5
}
const
xAxisDates
=
getTodayAndPreviousDays
(
amountOfCycleDays
).
map
(
jsDate
=>
{
return
LocalDate
.
of
(
return
LocalDate
.
of
(
jsDate
.
getFullYear
(),
jsDate
.
getFullYear
(),
jsDate
.
getMonth
()
+
1
,
jsDate
.
getMonth
()
+
1
,
...
@@ -85,7 +92,7 @@ function makeColumnInfo(n) {
...
@@ -85,7 +92,7 @@ function makeColumnInfo(n) {
})
})
}
}
function
getPreviousDays
(
n
)
{
function
get
TodayAnd
PreviousDays
(
n
)
{
const
today
=
new
Date
()
const
today
=
new
Date
()
today
.
setHours
(
0
)
today
.
setHours
(
0
)
today
.
setMinutes
(
0
)
today
.
setMinutes
(
0
)
...
...
This diff is collapsed.
Click to expand it.
components/chart/config.js
+
1
−
2
View file @
cd1e689a
...
@@ -4,8 +4,7 @@ const config = {
...
@@ -4,8 +4,7 @@ const config = {
temperatureScale
:
{
temperatureScale
:
{
low
:
35
,
low
:
35
,
high
:
38
high
:
38
},
}
xAxisRangeInDays
:
1000
}
}
const
margin
=
3
const
margin
=
3
...
...
This diff is collapsed.
Click to expand it.
components/chart/day-column.js
+
0
−
1
View file @
cd1e689a
...
@@ -57,7 +57,6 @@ export default class DayColumn extends Component {
...
@@ -57,7 +57,6 @@ export default class DayColumn extends Component {
}
}
if
(
typeof
mucus
===
'
number
'
)
{
if
(
typeof
mucus
===
'
number
'
)
{
console
.
log
(
'
ever
'
)
const
mucusIcon
=
(
const
mucusIcon
=
(
<
View
<
View
position
=
'
absolute
'
position
=
'
absolute
'
...
...
This diff is collapsed.
Click to expand it.
db/index.js
+
12
−
2
View file @
cd1e689a
import
Realm
from
'
realm
'
import
Realm
from
'
realm
'
import
{
LocalDate
}
from
'
js-joda
'
import
{
LocalDate
,
ChronoUnit
}
from
'
js-joda
'
import
{
import
{
cycleWithTempAndNoMucusShift
,
cycleWithTempAndNoMucusShift
,
cycleWithFhm
,
cycleWithFhm
,
...
@@ -193,6 +193,15 @@ function getColumnNamesForCsv() {
...
@@ -193,6 +193,15 @@ function getColumnNamesForCsv() {
}
}
}
}
function
getAmountOfCycleDays
()
{
const
amountOfCycleDays
=
cycleDaysSortedByDate
.
length
if
(
!
amountOfCycleDays
)
return
0
const
earliest
=
cycleDaysSortedByDate
[
amountOfCycleDays
-
1
]
const
today
=
LocalDate
.
now
()
const
earliestAsLocalDate
=
LocalDate
.
parse
(
earliest
.
date
)
return
earliestAsLocalDate
.
until
(
today
,
ChronoUnit
.
DAYS
)
}
export
{
export
{
saveSymptom
,
saveSymptom
,
getOrCreateCycleDay
,
getOrCreateCycleDay
,
...
@@ -203,5 +212,6 @@ export {
...
@@ -203,5 +212,6 @@ export {
deleteAll
,
deleteAll
,
getPreviousTemperature
,
getPreviousTemperature
,
getCycleDay
,
getCycleDay
,
getColumnNamesForCsv
getColumnNamesForCsv
,
getAmountOfCycleDays
}
}
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