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
0e2a3543
Commit
0e2a3543
authored
Mar 08, 2018
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix timescale prometheus charts overlapping
parent
7623cae9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+9
-0
app/assets/javascripts/monitoring/components/graph.vue
app/assets/javascripts/monitoring/components/graph.vue
+18
-2
spec/javascripts/datetime_utility_spec.js
spec/javascripts/datetime_utility_spec.js
+9
-0
No files found.
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
0e2a3543
...
...
@@ -291,6 +291,15 @@ 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 @
0e2a3543
<
script
>
import
{
scaleLinear
,
scaleTime
}
from
'
d3-scale
'
;
import
{
axisLeft
,
axisBottom
}
from
'
d3-axis
'
;
import
{
max
,
extent
}
from
'
d3-array
'
;
import
{
max
,
extent
,
min
}
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
'
;
...
...
@@ -14,7 +16,7 @@
import
createTimeSeries
from
'
../utils/multiple_time_series
'
;
import
bp
from
'
../../breakpoints
'
;
const
d3
=
{
scaleLinear
,
scaleTime
,
axisLeft
,
axisBottom
,
max
,
extent
,
select
};
const
d3
=
{
scaleLinear
,
scaleTime
,
axisLeft
,
axisBottom
,
max
,
min
,
extent
,
select
,
timeMinute
};
export
default
{
components
:
{
...
...
@@ -206,9 +208,23 @@
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
))
.
tickFormat
(
timeScaleFormat
);
const
yAxis
=
d3
.
axisLeft
()
...
...
spec/javascripts/datetime_utility_spec.js
View file @
0e2a3543
...
...
@@ -170,3 +170,12 @@ 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