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
290217d5
Commit
290217d5
authored
Sep 07, 2017
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved color selector and addressed observations
parent
ce27b99f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
51 deletions
+38
-51
app/assets/javascripts/monitoring/components/graph/legend.vue
...assets/javascripts/monitoring/components/graph/legend.vue
+1
-1
app/assets/javascripts/monitoring/utils/multiple_time_series.js
...sets/javascripts/monitoring/utils/multiple_time_series.js
+37
-50
No files found.
app/assets/javascripts/monitoring/components/graph/legend.vue
View file @
290217d5
...
...
@@ -171,7 +171,7 @@
ref=
"legendTitleSvg"
x=
"38"
:y=
"graphHeight - 30"
>
{{
createSeriesString
(
index
,
series
)
}}
{{
createSeriesString
(
index
,
series
)
}}
</text>
<text
v-else
...
...
app/assets/javascripts/monitoring/utils/multiple_time_series.js
View file @
290217d5
import
d3
from
'
d3
'
;
import
_
from
'
underscore
'
;
function
pickColorFromNameNumber
(
colorName
,
colorNumber
)
{
let
lineColor
=
''
;
let
areaColor
=
''
;
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
;
}
const
defaultColorPalette
=
{
blue
:
[
'
#1f78d1
'
,
'
#8fbce8
'
],
orange
:
[
'
#fc9403
'
,
'
#feca81
'
],
red
:
[
'
#db3b21
'
,
'
#ed9d90
'
],
green
:
[
'
#1aaa55
'
,
'
#8dd5aa
'
],
purple
:
[
'
#6666c4
'
,
'
#d1d1f0
'
],
};
return
{
lineColor
,
areaColor
,
};
const
defaultColorOrder
=
[
'
blue
'
,
'
orange
'
,
'
red
'
,
'
green
'
,
'
purple
'
];
let
usedColors
=
[];
function
pickColor
(
name
)
{
let
pick
;
if
(
name
&&
defaultColorPalette
[
name
])
{
pick
=
name
;
}
else
{
const
unusedColors
=
_
.
difference
(
defaultColorOrder
,
usedColors
);
if
(
unusedColors
.
length
>
0
)
{
pick
=
unusedColors
[
0
];
}
else
{
usedColors
=
[];
pick
=
defaultColorOrder
[
0
];
}
}
usedColors
.
push
(
pick
);
return
defaultColorPalette
[
pick
];
}
export
default
function
createTimeSeries
(
queryData
,
graphWidth
,
graphHeight
,
graphHeightOffset
)
{
...
...
@@ -56,9 +41,10 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra
let
timeSeriesNumber
=
1
;
return
queryData
.
result
.
map
((
timeSeries
,
index
)
=>
{
return
queryData
.
result
.
map
((
timeSeries
)
=>
{
let
metricTag
=
''
;
let
pathColors
=
null
;
let
lineColor
=
'
#1f78d1
'
;
let
areaColor
=
'
#8fbce8
'
;
const
timeSeriesScaleX
=
d3
.
time
.
scale
()
.
range
([
0
,
graphWidth
-
70
]);
...
...
@@ -70,33 +56,33 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra
timeSeriesScaleY
.
domain
([
0
,
maxValueFromSeries
.
maxValue
]);
const
lineFunction
=
d3
.
svg
.
line
()
.
interpolate
(
'
step-before
'
)
.
interpolate
(
'
linear
'
)
.
x
(
d
=>
timeSeriesScaleX
(
d
.
time
))
.
y
(
d
=>
timeSeriesScaleY
(
d
.
value
));
const
areaFunction
=
d3
.
svg
.
area
()
.
interpolate
(
'
step-before
'
)
.
interpolate
(
'
linear
'
)
.
x
(
d
=>
timeSeriesScaleX
(
d
.
time
))
.
y0
(
graphHeight
-
graphHeightOffset
)
.
y1
(
d
=>
timeSeriesScaleY
(
d
.
value
));
if
(
queryData
.
series
!=
null
)
{
const
seriesCustomizationData
=
queryData
.
series
[
index
];
const
timeSeriesMetricLabel
=
timeSeries
.
metric
[
Object
.
keys
(
timeSeries
.
metric
)[
0
]];
const
seriesCustomizationData
=
_
.
findWhere
(
queryData
.
series
[
0
].
series
,
{
value
:
timeSeriesMetricLabel
});
if
(
seriesCustomizationData
!=
null
)
{
metricTag
=
seriesCustomizationData
.
value
||
timeSeriesMetricLabel
;
if
(
seriesCustomizationData
.
color
!=
null
)
{
pathColors
=
pickColorFromNameNumber
(
seriesCustomizationData
.
color
.
toLowerCase
(),
null
);
[
lineColor
,
areaColor
]
=
pickColor
(
seriesCustomizationData
.
color
);
}
else
{
[
lineColor
,
areaColor
]
=
pickColor
();
}
}
else
{
metricTag
=
timeSeriesMetricLabel
||
`series
${
timeSeriesNumber
}
`
;
[
lineColor
,
areaColor
]
=
pickColor
();
}
}
if
(
pathColors
==
null
)
{
pathColors
=
pickColorFromNameNumber
(
null
,
timeSeriesNumber
);
}
if
(
timeSeriesNumber
<=
5
)
{
timeSeriesNumber
=
timeSeriesNumber
+=
1
;
}
else
{
...
...
@@ -108,7 +94,8 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra
areaPath
:
areaFunction
(
timeSeries
.
values
),
timeSeriesScaleX
,
values
:
timeSeries
.
values
,
...
pathColors
,
lineColor
,
areaColor
,
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