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
Boxiang Sun
gitlab-ce
Commits
45900c30
Commit
45900c30
authored
Aug 31, 2017
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for named colors, also added interpolations for the graphs
parent
057e84d6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
17 deletions
+85
-17
app/assets/javascripts/lib/utils/number_utils.js
app/assets/javascripts/lib/utils/number_utils.js
+1
-1
app/assets/javascripts/monitoring/components/graph.vue
app/assets/javascripts/monitoring/components/graph.vue
+2
-4
app/assets/javascripts/monitoring/components/graph/legend.vue
...assets/javascripts/monitoring/components/graph/legend.vue
+8
-1
app/assets/javascripts/monitoring/utils/multiple_time_series.js
...sets/javascripts/monitoring/utils/multiple_time_series.js
+74
-11
No files found.
app/assets/javascripts/lib/utils/number_utils.js
View file @
45900c30
...
...
@@ -13,7 +13,7 @@ export function formatRelevantDigits(number) {
let
relevantDigits
=
0
;
let
formattedNumber
=
''
;
if
(
!
isNaN
(
Number
(
number
)))
{
digitsLeft
=
number
.
split
(
'
.
'
)[
0
];
digitsLeft
=
number
.
toString
().
split
(
'
.
'
)[
0
];
switch
(
digitsLeft
.
length
)
{
case
1
:
relevantDigits
=
3
;
...
...
app/assets/javascripts/monitoring/components/graph.vue
View file @
45900c30
...
...
@@ -40,8 +40,6 @@
graphHeightOffset
:
120
,
margin
:
{},
unitOfDisplay
:
''
,
areaColorRgb
:
'
#8fbce8
'
,
lineColorRgb
:
'
#1f78d1
'
,
yAxisLabel
:
''
,
legendTitle
:
''
,
reducedDeploymentData
:
[],
...
...
@@ -143,7 +141,7 @@
},
renderAxesPaths
()
{
this
.
timeSeries
=
createTimeSeries
(
this
.
graphData
.
queries
[
0
]
.
result
,
this
.
timeSeries
=
createTimeSeries
(
this
.
graphData
.
queries
[
0
],
this
.
graphWidth
,
this
.
graphHeight
,
this
.
graphHeightOffset
);
...
...
@@ -162,7 +160,7 @@
const
xAxis
=
d3
.
svg
.
axis
()
.
scale
(
axisXScale
)
.
ticks
(
measurements
.
xTicks
)
.
ticks
(
d3
.
time
.
minute
,
60
)
.
tickFormat
(
timeScaleFormat
)
.
orient
(
'
bottom
'
);
...
...
app/assets/javascripts/monitoring/components/graph/legend.vue
View file @
45900c30
...
...
@@ -81,6 +81,13 @@
formatMetricUsage
(
series
)
{
return
`
${
formatRelevantDigits
(
series
.
values
[
this
.
currentDataIndex
].
value
)}
${
this
.
unitOfDisplay
}
`
;
},
createSeriesString
(
index
,
series
)
{
if
(
series
.
metricTag
)
{
return
`
${
series
.
metricTag
}
${
this
.
formatMetricUsage
(
series
)}
`
;
}
return
`
${
this
.
legendTitle
}
series
${
index
+
1
}
${
this
.
formatMetricUsage
(
series
)}
`
;
},
},
mounted
()
{
this
.
$nextTick
(()
=>
{
...
...
@@ -164,7 +171,7 @@
ref=
"legendTitleSvg"
x=
"38"
:y=
"graphHeight - 30"
>
{{
legendTitle
}}
Series
{{
index
+
1
}}
{{
formatMetricUsage
(
series
)
}}
{{
createSeriesString
(
index
,
series
)
}}
</text>
<text
v-else
...
...
app/assets/javascripts/monitoring/utils/multiple_time_series.js
View file @
45900c30
import
d3
from
'
d3
'
;
import
_
from
'
underscore
'
;
export
default
function
createTimeSeries
(
seriesData
,
graphWidth
,
graphHeight
,
graphHeightOffset
)
{
const
maxValues
=
seriesData
.
map
((
timeSeries
,
index
)
=>
{
function
pickColorFromNameNumber
(
colorName
,
colorNumber
)
{
let
lineColor
=
'
#1f78d1
'
;
let
areaColor
=
'
#8fbce8
'
;
const
color
=
colorName
!=
null
?
colorName
:
colorNumber
;
switch
(
color
)
{
case
'
blue
'
:
case
1
:
lineColor
=
'
#1f78d1
'
;
areaColor
=
'
#8fbce8
'
;
break
;
case
'
orange
'
:
case
2
:
lineColor
=
'
#fc9403
'
;
areaColor
=
'
#feca81
'
;
break
;
case
'
red
'
:
case
3
:
lineColor
=
'
#db3b21
'
;
areaColor
=
'
#ed9d90
'
;
break
;
case
'
green
'
:
case
4
:
lineColor
=
'
#1aaa55
'
;
areaColor
=
'
#8dd5aa
'
;
break
;
case
'
purple
'
:
case
5
:
lineColor
=
'
#6666c4
'
;
areaColor
=
'
#d1d1f0
'
;
break
;
default
:
lineColor
=
'
#1f78d1
'
;
areaColor
=
'
#8fbce8
'
;
break
;
}
return
{
lineColor
,
areaColor
,
};
}
export
default
function
createTimeSeries
(
queryData
,
graphWidth
,
graphHeight
,
graphHeightOffset
)
{
const
maxValues
=
queryData
.
result
.
map
((
timeSeries
,
index
)
=>
{
const
maxValue
=
d3
.
max
(
timeSeries
.
values
.
map
(
d
=>
d
.
value
));
return
{
maxValue
,
...
...
@@ -18,7 +60,9 @@ export default function createTimeSeries(seriesData, graphWidth, graphHeight, gr
const
lineColors
=
[
'
#1f78d1
'
,
'
#fc9403
'
,
'
#db3b21
'
,
'
#1aaa55
'
,
'
#6666c4
'
];
const
areaColors
=
[
'
#8fbce8
'
,
'
#feca81
'
,
'
#ed9d90
'
,
'
#8dd5aa
'
,
'
#d1d1f0
'
];
return
seriesData
.
map
((
timeSeries
)
=>
{
return
queryData
.
result
.
map
((
timeSeries
,
index
)
=>
{
let
metricTag
=
'
series
'
;
let
pathColors
=
null
;
const
timeSeriesScaleX
=
d3
.
time
.
scale
()
.
range
([
0
,
graphWidth
-
70
]);
...
...
@@ -26,34 +70,53 @@ export default function createTimeSeries(seriesData, graphWidth, graphHeight, gr
.
range
([
graphHeight
-
graphHeightOffset
,
0
]);
timeSeriesScaleX
.
domain
(
d3
.
extent
(
timeSeries
.
values
,
d
=>
d
.
time
));
timeSeriesScaleX
.
ticks
(
d3
.
time
.
minute
,
60
);
timeSeriesScaleY
.
domain
([
0
,
maxValueFromSeries
.
maxValue
]);
const
lineFunction
=
d3
.
svg
.
line
()
.
interpolate
(
'
step-before
'
)
.
x
(
d
=>
timeSeriesScaleX
(
d
.
time
))
.
y
(
d
=>
timeSeriesScaleY
(
d
.
value
));
const
areaFunction
=
d3
.
svg
.
area
()
.
interpolate
(
'
step-before
'
)
.
x
(
d
=>
timeSeriesScaleX
(
d
.
time
))
.
y0
(
graphHeight
-
graphHeightOffset
)
.
y1
(
d
=>
timeSeriesScaleY
(
d
.
value
))
.
interpolate
(
'
linear
'
);
.
y1
(
d
=>
timeSeriesScaleY
(
d
.
value
));
lineColor
=
lineColors
[
timeSeriesNumber
-
1
];
areaColor
=
areaColors
[
timeSeriesNumber
-
1
];
if
(
queryData
.
series
!=
null
)
{
const
seriesCustomizationData
=
queryData
.
series
[
index
];
metricTag
=
timeSeries
.
metric
[
Object
.
keys
(
timeSeries
.
metric
)[
0
]]
||
''
;
if
(
seriesCustomizationData
!=
null
)
{
if
(
seriesCustomizationData
.
value
===
metricTag
&&
seriesCustomizationData
.
color
!=
null
)
{
pathColors
=
pickColorFromNameNumber
(
seriesCustomizationData
.
color
.
toLowerCase
(),
null
);
}
}
}
if
(
pathColors
==
null
)
{
pathColors
=
pickColorFromNameNumber
(
null
,
timeSeriesNumber
);
if
(
timeSeriesNumber
<=
5
)
{
timeSeriesNumber
=
timeSeriesNumber
+=
1
;
}
else
{
timeSeriesNumber
=
1
;
}
}
return
{
linePath
:
lineFunction
(
timeSeries
.
values
),
areaPath
:
areaFunction
(
timeSeries
.
values
),
timeSeriesScaleX
,
values
:
timeSeries
.
values
,
lineColor
,
areaColor
,
...
pathColors
,
metricTag
,
};
});
}
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