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
c43bc417
Commit
c43bc417
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Draws lines!
parent
3d12e5e4
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/day-column.js
+14
-13
14 additions, 13 deletions
components/chart/day-column.js
with
14 additions
and
13 deletions
components/chart/day-column.js
+
14
−
13
View file @
c43bc417
...
@@ -116,16 +116,20 @@ export default class DayColumn extends Component {
...
@@ -116,16 +116,20 @@ export default class DayColumn extends Component {
let
lineToRight
let
lineToRight
let
lineToLeft
let
lineToLeft
function
makeLine
(
leftY
,
rightY
,
leftX
,
excludeLine
)
{
function
makeLine
(
leftY
,
rightY
,
direction
,
excludeLine
)
{
const
heightDiff
=
leftY
-
rightY
const
colWidth
=
config
.
columnWidth
const
angle
=
Math
.
atan2
(
config
.
columnWidth
,
heightDiff
)
const
heightDiff
=
-
leftY
-
-
rightY
const
angle
=
Math
.
atan2
(
heightDiff
,
colWidth
/
2
)
const
lineStyle
=
excludeLine
?
styles
.
curveExcluded
:
styles
.
curve
const
lineStyle
=
excludeLine
?
styles
.
curveExcluded
:
styles
.
curve
// hypotenuse
// hypotenuse
const
h
=
(
config
.
columnWidth
/
2
)
/
Math
.
cos
(
angle
)
const
h
=
(
colWidth
/
2
)
/
Math
.
cos
(
angle
)
const
neededDiff
=
Math
.
sin
(
Math
.
PI
-
(
angle
+
Math
.
PI
/
2
))
*
(
h
/
2
)
// the rotation by default rotates from the middle of the line,
const
projectedX
=
leftX
-
((
h
/
2
)
-
neededDiff
)
// but we want the transform origin to be at its beginning
console
.
log
(
leftX
)
// react native doesn't have transformOrigin, so we do this manually
console
.
log
(
projectedX
)
// 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
return
(
<
View
width
=
{
h
}
width
=
{
h
}
...
@@ -133,9 +137,6 @@ export default class DayColumn extends Component {
...
@@ -133,9 +137,6 @@ export default class DayColumn extends Component {
top
=
{(
leftY
+
rightY
)
/
2
}
top
=
{(
leftY
+
rightY
)
/
2
}
left
=
{
projectedX
}
left
=
{
projectedX
}
style
=
{{
style
=
{{
// 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
transform
:
[
transform
:
[
{
rotateZ
:
`
${
angle
}
rad`
}
{
rotateZ
:
`
${
angle
}
rad`
}
],
],
...
@@ -147,12 +148,12 @@ export default class DayColumn extends Component {
...
@@ -147,12 +148,12 @@ export default class DayColumn extends Component {
if
(
this
.
props
.
leftY
)
{
if
(
this
.
props
.
leftY
)
{
const
middleY
=
((
this
.
props
.
leftY
-
currY
)
/
2
)
+
currY
const
middleY
=
((
this
.
props
.
leftY
-
currY
)
/
2
)
+
currY
const
excludedLine
=
this
.
props
.
leftTemperatureExclude
||
exclude
const
excludedLine
=
this
.
props
.
leftTemperatureExclude
||
exclude
lineToLeft
=
makeLine
(
middleY
,
currY
,
0
,
excludedLine
)
lineToLeft
=
makeLine
(
middleY
,
currY
,
'
left
'
,
excludedLine
)
}
}
if
(
this
.
props
.
rightY
)
{
if
(
this
.
props
.
rightY
)
{
const
middleY
=
((
currY
-
this
.
props
.
rightY
)
/
2
)
+
this
.
props
.
rightY
const
middleY
=
((
currY
-
this
.
props
.
rightY
)
/
2
)
+
this
.
props
.
rightY
const
excludedLine
=
this
.
props
.
rightTemperatureExclude
||
exclude
const
excludedLine
=
this
.
props
.
rightTemperatureExclude
||
exclude
lineToRight
=
makeLine
(
currY
,
middleY
,
config
.
columnMiddle
,
excludedLine
)
lineToRight
=
makeLine
(
currY
,
middleY
,
'
right
'
,
excludedLine
)
}
}
const
dotStyle
=
exclude
?
styles
.
curveDotsExcluded
:
styles
.
curveDots
const
dotStyle
=
exclude
?
styles
.
curveDotsExcluded
:
styles
.
curveDots
...
...
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