Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
f2247c65
Commit
f2247c65
authored
Mar 12, 2018
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use graph width to determine tick number
parent
0e2a3543
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
36 deletions
+3
-36
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+0
-9
app/assets/javascripts/monitoring/components/graph.vue
app/assets/javascripts/monitoring/components/graph.vue
+3
-18
spec/javascripts/datetime_utility_spec.js
spec/javascripts/datetime_utility_spec.js
+0
-9
No files found.
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
f2247c65
...
...
@@ -291,15 +291,6 @@ export const getTimeframeWindow = (length, date) => {
return
timeframe
;
};
/**
* Returns the time difference between two dates in minutes
*
* @param {Date} dateStart
* @param {Date} dateEnd
*/
export
const
timeDifferenceMinutes
=
(
dateStart
,
dateEnd
)
=>
(
dateEnd
-
dateStart
)
/
1000
/
60
;
window
.
gl
=
window
.
gl
||
{};
window
.
gl
.
utils
=
{
...(
window
.
gl
.
utils
||
{}),
...
...
app/assets/javascripts/monitoring/components/graph.vue
View file @
f2247c65
<
script
>
import
{
scaleLinear
,
scaleTime
}
from
'
d3-scale
'
;
import
{
axisLeft
,
axisBottom
}
from
'
d3-axis
'
;
import
{
max
,
extent
,
min
}
from
'
d3-array
'
;
import
{
max
,
extent
}
from
'
d3-array
'
;
import
{
select
}
from
'
d3-selection
'
;
import
{
timeMinute
}
from
'
d3-time
'
;
import
{
timeDifferenceMinutes
}
from
'
~/lib/utils/datetime_utility
'
;
import
GraphLegend
from
'
./graph/legend.vue
'
;
import
GraphFlag
from
'
./graph/flag.vue
'
;
import
GraphDeployment
from
'
./graph/deployment.vue
'
;
...
...
@@ -16,7 +14,7 @@
import
createTimeSeries
from
'
../utils/multiple_time_series
'
;
import
bp
from
'
../../breakpoints
'
;
const
d3
=
{
scaleLinear
,
scaleTime
,
axisLeft
,
axisBottom
,
max
,
min
,
extent
,
select
,
timeMinute
};
const
d3
=
{
scaleLinear
,
scaleTime
,
axisLeft
,
axisBottom
,
max
,
extent
,
select
};
export
default
{
components
:
{
...
...
@@ -208,23 +206,10 @@
const
allValues
=
this
.
timeSeries
.
reduce
((
all
,
{
values
})
=>
all
.
concat
(
values
),
[]);
axisXScale
.
domain
(
d3
.
extent
(
allValues
,
d
=>
d
.
time
));
axisYScale
.
domain
([
0
,
d3
.
max
(
allValues
.
map
(
d
=>
d
.
value
))]);
// time difference
const
dateEnd
=
d3
.
max
(
allValues
.
map
(
d
=>
d
.
time
));
const
dateStart
=
d3
.
min
(
allValues
.
map
(
d
=>
d
.
time
));
const
timeDifference
=
timeDifferenceMinutes
(
dateStart
,
dateEnd
);
let
timeTicks
;
if
(
timeDifference
>
90
)
{
timeTicks
=
60
;
}
else
if
(
timeDifference
>
45
&&
timeDifference
<=
90
)
{
timeTicks
=
30
;
}
else
if
(
timeDifference
<=
45
)
{
timeTicks
=
15
;
}
const
xAxis
=
d3
.
axisBottom
()
.
scale
(
axisXScale
)
.
ticks
(
d3
.
timeMinute
.
every
(
timeTicks
)
)
.
ticks
(
this
.
graphWidth
/
120
)
.
tickFormat
(
timeScaleFormat
);
const
yAxis
=
d3
.
axisLeft
()
...
...
spec/javascripts/datetime_utility_spec.js
View file @
f2247c65
...
...
@@ -170,12 +170,3 @@ describe('getTimeframeWindow', () => {
});
});
});
describe
(
'
timeDifferenceMinutes
'
,
()
=>
{
it
(
'
returns the time difference between two dates in minutes
'
,
()
=>
{
const
dateStart
=
new
Date
(
'
2018-03-08 12:00:00
'
);
const
dateEnd
=
new
Date
(
'
2018-03-08 13:00:00
'
);
expect
(
datetimeUtility
.
timeDifferenceMinutes
(
dateStart
,
dateEnd
)).
toEqual
(
60
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment