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
53e22110
Commit
53e22110
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Remove ScrollView and make DayColumn component
parent
f5b37161
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/chart/chart.js
+57
-43
57 additions, 43 deletions
components/chart/chart.js
with
57 additions
and
43 deletions
components/chart/chart.js
+
57
−
43
View file @
53e22110
import
React
,
{
Component
}
from
'
react
'
import
{
Text
as
ReactNativeText
,
View
,
FlatList
,
ScrollView
}
from
'
react-native
'
import
{
Text
as
ReactNativeText
,
View
,
FlatList
}
from
'
react-native
'
import
range
from
'
date-range
'
import
Svg
,{
G
,
...
...
@@ -45,21 +45,36 @@ export default class CycleChart extends Component {
this
.
props
.
navigation
.
navigate
(
'
cycleDay
'
,
{
cycleDay
})
}
placeHorizontalGrid
()
{
return
yAxis
.
tickPositions
.
map
(
tick
=>
{
return
(
<
Line
x1
=
{
0
}
y1
=
{
tick
}
x2
=
{
config
.
columnWidth
}
y2
=
{
tick
}
{...
styles
.
horizontalGrid
}
key
=
{
tick
}
/
>
)
})
render
()
{
return
(
<
View
style
=
{{
flexDirection
:
'
row
'
}}
>
<
View
{...
styles
.
yAxis
}
>
{
yAxis
.
labels
}
<
/View
>
<
FlatList
horizontal
=
{
true
}
inverted
=
{
true
}
showsHorizontalScrollIndicator
=
{
false
}
data
=
{
this
.
state
.
columns
}
renderItem
=
{({
item
,
index
})
=>
{
const
cols
=
this
.
state
.
columns
return
(
<
DayColumn
item
=
{
item
}
index
=
{
index
}
rightNeighbor
=
{
index
>
0
?
cols
[
index
-
1
]
:
undefined
}
leftNeighbor
=
{
index
<
cols
.
length
-
1
?
cols
[
index
+
1
]
:
undefined
}
/
>
)
}}
keyExtractor
=
{
item
=>
item
.
dateString
}
initialNumToRender
=
{
20
}
>
<
/FlatList
>
<
/View
>
)
}
}
class
DayColumn
extends
Component
{
makeDayColumn
({
dateString
,
cycleDay
,
y
},
index
)
{
const
cycleDayNumber
=
getCycleDayNumber
(
dateString
)
const
label
=
styles
.
column
.
label
...
...
@@ -116,16 +131,15 @@ export default class CycleChart extends Component {
/> : null
}
{
y
?
this
.
drawDotAndLines
(
y
,
cycleDay
.
temperature
.
exclude
,
index
)
this
.
drawDotAndLines
(
y
,
cycleDay
.
temperature
.
exclude
)
:
null
}
<
/G
>
)
}
drawDotAndLines
(
currY
,
exclude
,
index
)
{
drawDotAndLines
(
currY
,
exclude
)
{
let
lineToRight
let
lineToLeft
const
cols
=
this
.
state
.
columns
function
makeLine
(
otherColY
,
x
,
excludeLine
)
{
const
middleY
=
((
otherColY
-
currY
)
/
2
)
+
currY
...
...
@@ -141,18 +155,18 @@ export default class CycleChart extends Component {
/
>
}
const
thereIsADotToTheRight
=
index
>
0
&&
cols
[
index
-
1
]
.
y
const
thereIsADotToTheLeft
=
index
<
cols
.
length
-
1
&&
cols
[
index
+
1
]
.
y
const
thereIsADotToTheRight
=
this
.
props
.
rightNeighbor
&&
this
.
props
.
rightNeighbor
.
y
const
thereIsADotToTheLeft
=
this
.
props
.
leftNeighbor
&&
this
.
props
.
leftNeighbor
.
y
if
(
thereIsADotToTheRight
)
{
const
otherDot
=
cols
[
index
-
1
]
const
excludedLine
=
otherDot
.
cycleDay
.
temperature
.
exclude
||
exclude
lineToRight
=
makeLine
(
otherDot
.
y
,
config
.
columnWidth
,
excludedLine
)
const
neighbor
=
this
.
props
.
rightNeighbor
const
excludedLine
=
neighbor
.
cycleDay
.
temperature
.
exclude
||
exclude
lineToRight
=
makeLine
(
neighbor
.
y
,
config
.
columnWidth
,
excludedLine
)
}
if
(
thereIsADotToTheLeft
)
{
const
otherDot
=
cols
[
index
+
1
]
const
excludedLine
=
otherDot
.
cycleDay
.
temperature
.
exclude
||
exclude
lineToLeft
=
makeLine
(
otherDot
.
y
,
0
,
excludedLine
)
const
neighbor
=
this
.
props
.
leftNeighbor
const
excludedLine
=
neighbor
.
cycleDay
.
temperature
.
exclude
||
exclude
lineToLeft
=
makeLine
(
neighbor
.
y
,
0
,
excludedLine
)
}
const
dotStyle
=
exclude
?
styles
.
curveDotsExcluded
:
styles
.
curveDots
...
...
@@ -167,26 +181,26 @@ export default class CycleChart extends Component {
<
/G>
)
}
placeHorizontalGrid
()
{
return
yAxis
.
tickPositions
.
map
(
tick
=>
{
return
(
<
Line
x1
=
{
0
}
y1
=
{
tick
}
x2
=
{
config
.
columnWidth
}
y2
=
{
tick
}
{...
styles
.
horizontalGrid
}
key
=
{
tick
}
/
>
)
})
}
render
()
{
return
(
<
ScrollView
contentContainerStyle
=
{{
flexDirection
:
'
row
'
}}
>
<
View
{...
styles
.
yAxis
}
>
{
yAxis
.
labels
}
<
/View
>
<
FlatList
horizontal
=
{
true
}
inverted
=
{
true
}
showsHorizontalScrollIndicator
=
{
false
}
data
=
{
this
.
state
.
columns
}
renderItem
=
{({
item
,
index
})
=>
{
return
(
<
Svg
width
=
{
config
.
columnWidth
}
height
=
{
config
.
chartHeight
}
>
{
this
.
makeDayColumn
(
item
,
index
)}
<
/Svg
>
)
}}
keyExtractor
=
{
item
=>
item
.
dateString
}
>
<
/FlatList
>
<
/ScrollView
>
<
Svg
width
=
{
config
.
columnWidth
}
height
=
{
config
.
chartHeight
}
>
{
this
.
makeDayColumn
(
this
.
props
.
item
,
this
.
props
.
index
)}
<
/Svg
>
)
}
}
...
...
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