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
Jérome Perrin
gitlab-ce
Commits
8a807aed
Commit
8a807aed
authored
Aug 29, 2017
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrected y scale for multiple time series and visual improvements
parent
80d8235b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
14 deletions
+19
-14
app/assets/javascripts/monitoring/components/graph/legend.vue
...assets/javascripts/monitoring/components/graph/legend.vue
+6
-10
app/assets/javascripts/monitoring/utils/multiple_time_series.js
...sets/javascripts/monitoring/utils/multiple_time_series.js
+12
-2
spec/javascripts/monitoring/graph/legend_spec.js
spec/javascripts/monitoring/graph/legend_spec.js
+1
-1
spec/javascripts/monitoring/utils/multiple_time_series_spec.js
...javascripts/monitoring/utils/multiple_time_series_spec.js
+0
-1
No files found.
app/assets/javascripts/monitoring/components/graph/legend.vue
View file @
8a807aed
...
@@ -163,24 +163,20 @@
...
@@ -163,24 +163,20 @@
:y=
"graphHeight - measurements.legendOffset"
>
:y=
"graphHeight - measurements.legendOffset"
>
</rect>
</rect>
<text
<text
v-if=
"timeSeries.length > 1"
class=
"legend-metric-title"
class=
"legend-metric-title"
ref=
"legendTitleSvg"
ref=
"legendTitleSvg"
x=
"38"
x=
"38"
:y=
"graphHeight - 30"
>
:y=
"graphHeight - 30"
>
{{
legendTitle
}}
{{
legendTitle
}}
Series
{{
index
+
1
}}
{{
formatMetricUsage
(
series
)
}}
</text>
</text>
<text
<text
v-else
class=
"legend-metric-title"
class=
"legend-metric-title"
ref=
"seriesTitleSvg"
ref=
"legendTitleSvg"
:x=
"seriesXPosition + 40"
x=
"38"
:y=
"graphHeight - 30"
>
Series
{{
index
+
1
}}
</text>
<text
class=
"text-metric-usage"
:x=
"metricUsageXPosition + seriesXPosition + 45"
:y=
"graphHeight - 30"
>
:y=
"graphHeight - 30"
>
{{
formatMetricUsage
(
series
)
}}
{{
legendTitle
}}
{{
formatMetricUsage
(
series
)
}}
</text>
</text>
</g>
</g>
</g>
</g>
...
...
app/assets/javascripts/monitoring/utils/multiple_time_series.js
View file @
8a807aed
import
d3
from
'
d3
'
;
import
d3
from
'
d3
'
;
import
_
from
'
underscore
'
;
export
default
function
createTimeSeries
(
seriesData
,
graphWidth
,
graphHeight
,
graphHeightOffset
)
{
export
default
function
createTimeSeries
(
seriesData
,
graphWidth
,
graphHeight
,
graphHeightOffset
)
{
const
maxValues
=
seriesData
.
map
((
timeSeries
,
index
)
=>
{
const
maxValue
=
d3
.
max
(
timeSeries
.
values
.
map
(
d
=>
d
.
value
));
return
{
maxValue
,
index
,
};
});
const
maxValueFromSeries
=
_
.
max
(
maxValues
,
val
=>
val
.
maxValue
);
return
seriesData
.
map
((
timeSeries
)
=>
{
return
seriesData
.
map
((
timeSeries
)
=>
{
const
timeSeriesScaleX
=
d3
.
time
.
scale
()
const
timeSeriesScaleX
=
d3
.
time
.
scale
()
.
range
([
0
,
graphWidth
-
70
]);
.
range
([
0
,
graphWidth
-
70
]);
...
@@ -9,7 +20,7 @@ export default function createTimeSeries(seriesData, graphWidth, graphHeight, gr
...
@@ -9,7 +20,7 @@ export default function createTimeSeries(seriesData, graphWidth, graphHeight, gr
.
range
([
graphHeight
-
graphHeightOffset
,
0
]);
.
range
([
graphHeight
-
graphHeightOffset
,
0
]);
timeSeriesScaleX
.
domain
(
d3
.
extent
(
timeSeries
.
values
,
d
=>
d
.
time
));
timeSeriesScaleX
.
domain
(
d3
.
extent
(
timeSeries
.
values
,
d
=>
d
.
time
));
timeSeriesScaleY
.
domain
([
0
,
d3
.
max
(
timeSeries
.
values
.
map
(
d
=>
d
.
value
))
]);
timeSeriesScaleY
.
domain
([
0
,
maxValueFromSeries
.
maxValue
]);
const
lineFunction
=
d3
.
svg
.
line
()
const
lineFunction
=
d3
.
svg
.
line
()
.
x
(
d
=>
timeSeriesScaleX
(
d
.
time
))
.
x
(
d
=>
timeSeriesScaleX
(
d
.
time
))
...
@@ -25,7 +36,6 @@ export default function createTimeSeries(seriesData, graphWidth, graphHeight, gr
...
@@ -25,7 +36,6 @@ export default function createTimeSeries(seriesData, graphWidth, graphHeight, gr
linePath
:
lineFunction
(
timeSeries
.
values
),
linePath
:
lineFunction
(
timeSeries
.
values
),
areaPath
:
areaFunction
(
timeSeries
.
values
),
areaPath
:
areaFunction
(
timeSeries
.
values
),
timeSeriesScaleX
,
timeSeriesScaleX
,
timeSeriesScaleY
,
values
:
timeSeries
.
values
,
values
:
timeSeries
.
values
,
};
};
});
});
...
...
spec/javascripts/monitoring/graph/legend_spec.js
View file @
8a807aed
...
@@ -93,7 +93,7 @@ describe('GraphLegend', () => {
...
@@ -93,7 +93,7 @@ describe('GraphLegend', () => {
const
component
=
createComponent
(
defaultValuesComponent
);
const
component
=
createComponent
(
defaultValuesComponent
);
const
titles
=
component
.
$el
.
querySelectorAll
(
'
.legend-metric-title
'
);
const
titles
=
component
.
$el
.
querySelectorAll
(
'
.legend-metric-title
'
);
expect
(
getTextFromNode
(
component
,
'
.legend-metric-title
'
)
).
toEqual
(
component
.
legendTitle
);
expect
(
getTextFromNode
(
component
,
'
.legend-metric-title
'
)
.
indexOf
(
component
.
legendTitle
)).
not
.
toEqual
(
-
1
);
expect
(
titles
[
0
].
textContent
.
indexOf
(
'
Title
'
)).
not
.
toEqual
(
-
1
);
expect
(
titles
[
0
].
textContent
.
indexOf
(
'
Title
'
)).
not
.
toEqual
(
-
1
);
expect
(
titles
[
1
].
textContent
.
indexOf
(
'
Series
'
)).
not
.
toEqual
(
-
1
);
expect
(
titles
[
1
].
textContent
.
indexOf
(
'
Series
'
)).
not
.
toEqual
(
-
1
);
expect
(
getTextFromNode
(
component
,
'
.y-label-text
'
)).
toEqual
(
component
.
yAxisLabel
);
expect
(
getTextFromNode
(
component
,
'
.y-label-text
'
)).
toEqual
(
component
.
yAxisLabel
);
...
...
spec/javascripts/monitoring/utils/multiple_time_series_spec.js
View file @
8a807aed
...
@@ -9,7 +9,6 @@ describe('Multiple time series', () => {
...
@@ -9,7 +9,6 @@ describe('Multiple time series', () => {
expect
(
typeof
timeSeries
[
0
].
linePath
).
toEqual
(
'
string
'
);
expect
(
typeof
timeSeries
[
0
].
linePath
).
toEqual
(
'
string
'
);
expect
(
typeof
timeSeries
[
0
].
areaPath
).
toEqual
(
'
string
'
);
expect
(
typeof
timeSeries
[
0
].
areaPath
).
toEqual
(
'
string
'
);
expect
(
typeof
timeSeries
[
0
].
timeSeriesScaleX
).
toEqual
(
'
function
'
);
expect
(
typeof
timeSeries
[
0
].
timeSeriesScaleX
).
toEqual
(
'
function
'
);
expect
(
typeof
timeSeries
[
0
].
timeSeriesScaleY
).
toEqual
(
'
function
'
);
expect
(
timeSeries
[
0
].
values
instanceof
Array
).
toEqual
(
true
);
expect
(
timeSeries
[
0
].
values
instanceof
Array
).
toEqual
(
true
);
});
});
...
...
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