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
7d6e45b1
Commit
7d6e45b1
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Draw dot and line with svg
parent
961009d7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
components/chart/day-column.js
+1
-1
1 addition, 1 deletion
components/chart/day-column.js
components/chart/dot-and-line.js
+16
-34
16 additions, 34 deletions
components/chart/dot-and-line.js
components/chart/styles.js
+10
-16
10 additions, 16 deletions
components/chart/styles.js
with
27 additions
and
51 deletions
components/chart/day-column.js
+
1
−
1
View file @
7d6e45b1
...
...
@@ -191,7 +191,7 @@ export default class DayColumn extends Component {
<
/View
>
<
/View
>
<
Svg
width
=
{
config
.
columnWidth
}
height
=
{
c
hart
Height
}
>
<
Svg
width
=
{
config
.
columnWidth
}
height
=
{
c
olumn
Height
}
>
{
column
}
<
/Svg
>
...
...
This diff is collapsed.
Click to expand it.
components/chart/dot-and-line.js
+
16
−
34
View file @
7d6e45b1
import
React
,
{
Component
}
from
'
react
'
import
{
View
}
from
'
react-native
'
import
{
Circle
,
Line
}
from
'
react-native-svg
'
import
styles
from
'
./styles
'
import
config
from
'
../../config
'
...
...
@@ -17,21 +18,20 @@ export default class DotAndLine extends Component {
if
(
this
.
props
.
leftY
)
{
const
middleY
=
((
this
.
props
.
leftY
-
y
)
/
2
)
+
y
const
excludedLine
=
this
.
props
.
leftTemperatureExclude
||
exclude
lineToLeft
=
makeLine
(
middleY
,
y
,
'
left
'
,
excludedLine
)
lineToLeft
=
makeLine
(
y
,
middleY
,
0
,
excludedLine
)
}
if
(
this
.
props
.
rightY
)
{
const
middleY
=
((
y
-
this
.
props
.
rightY
)
/
2
)
+
this
.
props
.
rightY
const
excludedLine
=
this
.
props
.
rightTemperatureExclude
||
exclude
lineToRight
=
makeLine
(
y
,
middleY
,
'
right
'
,
excludedLine
)
lineToRight
=
makeLine
(
y
,
middleY
,
config
.
columnWidth
,
excludedLine
)
}
const
dotStyle
=
exclude
?
styles
.
curveDotsExcluded
:
styles
.
curveDots
const
dot
=
(
<
View
position
=
'
absolute
'
top
=
{
y
-
(
dotStyle
.
height
/
2
)}
left
=
{
config
.
columnMiddle
-
(
dotStyle
.
width
/
2
)}
style
=
{
dotStyle
}
<
Circle
cx
=
{
config
.
columnMiddle
}
cy
=
{
y
}
{...
dotStyle
}
key
=
'
dot
'
/>
)
...
...
@@ -39,33 +39,15 @@ export default class DotAndLine extends Component {
}
}
function
makeLine
(
leftY
,
rightY
,
direction
,
excludeLine
)
{
const
colWidth
=
config
.
columnWidth
const
heightDiff
=
-
(
leftY
-
rightY
)
const
angle
=
Math
.
atan2
(
heightDiff
,
colWidth
/
2
)
function
makeLine
(
currY
,
middleY
,
x
,
excludeLine
)
{
const
lineStyle
=
excludeLine
?
styles
.
curveExcluded
:
styles
.
curve
// hypotenuse, we add 3px for good measure, because otherwise the lines
// don't quite touch at the day border
const
h
=
(
colWidth
/
2
)
/
Math
.
cos
(
angle
)
+
10
// the rotation by default rotates from the middle of the line,
// but we want the transform origin to be at its beginning
// react native doesn't have transformOrigin, so we do this manually
// if it's the right line, we put the pivot at 3/4 of the column
// if it's to the left, at 1/4
const
pivot
=
direction
===
'
right
'
?
colWidth
/
4
:
-
(
colWidth
/
4
)
const
projectedX
=
-
(
h
-
colWidth
)
/
2
+
pivot
return
(
<
View
width
=
{
h
}
position
=
'
absolute
'
top
=
{((
leftY
+
rightY
)
/
2
)
-
lineStyle
.
borderWidth
/
2
}
left
=
{
projectedX
}
style
=
{{
transform
:
[
{
rotateZ
:
`
${
angle
}
rad`
}
],
}}
return
<
Line
x1
=
{
config
.
columnMiddle
}
y1
=
{
currY
}
x2
=
{
x
}
y2
=
{
middleY
}
{...
lineStyle
}
key
=
{
direction
}
/>
)
key
=
{
x
.
toString
()
}
/
>
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
components/chart/styles.js
+
10
−
16
View file @
7d6e45b1
...
...
@@ -3,32 +3,26 @@ import {primaryColor, shadesOfRed} from '../../styles/index'
const
colorTemperature
=
'
#765285
'
const
colorTemperatureLight
=
'
#a67fb5
'
const
dot
Width
=
10
const
lineWidth
=
2
const
dot
Radius
=
5
const
lineWidth
=
1.5
const
colorLtl
=
'
#feb47b
'
const
styles
=
{
curve
:
{
borderStyle
:
'
solid
'
,
borderColor
:
colorTemperature
,
borderWidth
:
lineWidth
,
stroke
:
colorTemperature
,
strokeWidth
:
lineWidth
,
},
curveExcluded
:
{
borderColor
:
colorTemperatureLight
,
borderWidth
:
lineWidth
,
borderStyle
:
'
dotted
'
stroke
:
colorTemperatureLight
,
strokeWidth
:
lineWidth
},
curveDots
:
{
backgroundColor
:
colorTemperature
,
width
:
dotWidth
,
height
:
dotWidth
,
borderRadius
:
50
fill
:
colorTemperature
,
r
:
dotRadius
},
curveDotsExcluded
:
{
backgroundColor
:
colorTemperatureLight
,
width
:
dotWidth
,
height
:
dotWidth
,
borderRadius
:
50
fill
:
colorTemperatureLight
,
r
:
dotRadius
},
column
:
{
label
:
{
...
...
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