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
1f7ecf9a
Commit
1f7ecf9a
authored
Nov 05, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
process all queries within a graph
parent
309c1e6b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
16 deletions
+24
-16
app/assets/javascripts/monitoring/utils/multiple_time_series.js
...sets/javascripts/monitoring/utils/multiple_time_series.js
+24
-16
No files found.
app/assets/javascripts/monitoring/utils/multiple_time_series.js
View file @
1f7ecf9a
...
@@ -11,8 +11,9 @@ const defaultColorPalette = {
...
@@ -11,8 +11,9 @@ const defaultColorPalette = {
const
defaultColorOrder
=
[
'
blue
'
,
'
orange
'
,
'
red
'
,
'
green
'
,
'
purple
'
];
const
defaultColorOrder
=
[
'
blue
'
,
'
orange
'
,
'
red
'
,
'
green
'
,
'
purple
'
];
export
default
function
createTimeSeries
(
queries
,
graphWidth
,
graphHeight
,
graphHeightOffset
)
{
const
defaultStyleOrder
=
[
'
solid
'
,
'
dashed
'
,
'
dotted
'
];
const
queryData
=
queries
[
0
];
function
queryTimeSeries
(
query
,
graphWidth
,
graphHeight
,
graphHeightOffset
,
maxValue
,
lineStyle
)
{
let
usedColors
=
[];
let
usedColors
=
[];
function
pickColor
(
name
)
{
function
pickColor
(
name
)
{
...
@@ -32,17 +33,7 @@ export default function createTimeSeries(queries, graphWidth, graphHeight, graph
...
@@ -32,17 +33,7 @@ export default function createTimeSeries(queries, graphWidth, graphHeight, graph
return
defaultColorPalette
[
pick
];
return
defaultColorPalette
[
pick
];
}
}
const
maxValues
=
queryData
.
result
.
map
((
timeSeries
,
index
)
=>
{
return
query
.
result
.
map
((
timeSeries
,
timeSeriesNumber
)
=>
{
const
maxValue
=
d3
.
max
(
timeSeries
.
values
.
map
(
d
=>
d
.
value
));
return
{
maxValue
,
index
,
};
});
const
maxValueFromSeries
=
_
.
max
(
maxValues
,
val
=>
val
.
maxValue
);
return
queryData
.
result
.
map
((
timeSeries
,
timeSeriesNumber
)
=>
{
let
metricTag
=
''
;
let
metricTag
=
''
;
let
lineColor
=
''
;
let
lineColor
=
''
;
let
areaColor
=
''
;
let
areaColor
=
''
;
...
@@ -55,7 +46,7 @@ export default function createTimeSeries(queries, graphWidth, graphHeight, graph
...
@@ -55,7 +46,7 @@ export default function createTimeSeries(queries, graphWidth, graphHeight, graph
timeSeriesScaleX
.
domain
(
d3
.
extent
(
timeSeries
.
values
,
d
=>
d
.
time
));
timeSeriesScaleX
.
domain
(
d3
.
extent
(
timeSeries
.
values
,
d
=>
d
.
time
));
timeSeriesScaleX
.
ticks
(
d3
.
time
.
minute
,
60
);
timeSeriesScaleX
.
ticks
(
d3
.
time
.
minute
,
60
);
timeSeriesScaleY
.
domain
([
0
,
maxValue
FromSeries
.
maxValue
]);
timeSeriesScaleY
.
domain
([
0
,
maxValue
]);
const
defined
=
d
=>
!
isNaN
(
d
.
value
)
&&
d
.
value
!=
null
;
const
defined
=
d
=>
!
isNaN
(
d
.
value
)
&&
d
.
value
!=
null
;
...
@@ -73,8 +64,8 @@ export default function createTimeSeries(queries, graphWidth, graphHeight, graph
...
@@ -73,8 +64,8 @@ export default function createTimeSeries(queries, graphWidth, graphHeight, graph
.
y1
(
d
=>
timeSeriesScaleY
(
d
.
value
));
.
y1
(
d
=>
timeSeriesScaleY
(
d
.
value
));
const
timeSeriesMetricLabel
=
timeSeries
.
metric
[
Object
.
keys
(
timeSeries
.
metric
)[
0
]];
const
timeSeriesMetricLabel
=
timeSeries
.
metric
[
Object
.
keys
(
timeSeries
.
metric
)[
0
]];
const
seriesCustomizationData
=
query
Data
.
series
!=
null
&&
const
seriesCustomizationData
=
query
.
series
!=
null
&&
_
.
findWhere
(
query
Data
.
series
[
0
].
when
,
_
.
findWhere
(
query
.
series
[
0
].
when
,
{
value
:
timeSeriesMetricLabel
});
{
value
:
timeSeriesMetricLabel
});
if
(
seriesCustomizationData
!=
null
)
{
if
(
seriesCustomizationData
!=
null
)
{
metricTag
=
seriesCustomizationData
.
value
||
timeSeriesMetricLabel
;
metricTag
=
seriesCustomizationData
.
value
||
timeSeriesMetricLabel
;
...
@@ -89,9 +80,26 @@ export default function createTimeSeries(queries, graphWidth, graphHeight, graph
...
@@ -89,9 +80,26 @@ export default function createTimeSeries(queries, graphWidth, graphHeight, graph
areaPath
:
areaFunction
(
timeSeries
.
values
),
areaPath
:
areaFunction
(
timeSeries
.
values
),
timeSeriesScaleX
,
timeSeriesScaleX
,
values
:
timeSeries
.
values
,
values
:
timeSeries
.
values
,
lineStyle
,
lineColor
,
lineColor
,
areaColor
,
areaColor
,
metricTag
,
metricTag
,
};
};
});
});
}
}
export
default
function
createTimeSeries
(
queries
,
graphWidth
,
graphHeight
,
graphHeightOffset
)
{
const
maxValue
=
d3
.
max
(
queries
.
map
(
query
=>
(
d3
.
max
(
query
.
result
.
map
(
resultSet
=>
(
d3
.
max
(
resultSet
.
values
.
map
(
d
=>
d
.
value
))
)))
)));
return
queries
.
reduce
((
series
,
query
,
index
)
=>
{
const
lineStyle
=
defaultStyleOrder
[
index
%
defaultStyleOrder
.
length
];
return
series
.
concat
(
queryTimeSeries
(
query
,
graphWidth
,
graphHeight
,
graphHeightOffset
,
maxValue
,
lineStyle
),
);
},
[]);
}
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