Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
0994350e
Unverified
Commit
0994350e
authored
Sep 12, 2019
by
Dominik Prokop
Committed by
GitHub
Sep 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TimeSeries: Add data frame index and field name (#19005)
parent
c2dea633
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
3 deletions
+40
-3
public/app/core/time_series2.ts
+14
-0
public/app/plugins/panel/graph/data_processor.ts
+14
-3
public/app/plugins/panel/graph/specs/__snapshots__/data_processor.test.ts.snap
+12
-0
No files found.
public/app/core/time_series2.ts
View file @
0994350e
...
@@ -67,9 +67,21 @@ export function getDataMinMax(data: TimeSeries[]) {
...
@@ -67,9 +67,21 @@ export function getDataMinMax(data: TimeSeries[]) {
return
{
datamin
,
datamax
};
return
{
datamin
,
datamax
};
}
}
/**
* @deprecated: This class should not be used in new panels
*
* Use DataFrame and helpers instead
*/
export
default
class
TimeSeries
{
export
default
class
TimeSeries
{
datapoints
:
any
;
datapoints
:
any
;
id
:
string
;
id
:
string
;
// Represents index of original data frame in the quey response
dataFrameIndex
:
number
;
/**
* Name of the field the time series was created from
* Used in graph panel to retrieve value from the original data frame
*/
fieldName
:
string
;
label
:
string
;
label
:
string
;
alias
:
string
;
alias
:
string
;
aliasEscaped
:
string
;
aliasEscaped
:
string
;
...
@@ -110,6 +122,8 @@ export default class TimeSeries {
...
@@ -110,6 +122,8 @@ export default class TimeSeries {
this
.
stats
=
{};
this
.
stats
=
{};
this
.
legend
=
true
;
this
.
legend
=
true
;
this
.
unit
=
opts
.
unit
;
this
.
unit
=
opts
.
unit
;
this
.
fieldName
=
opts
.
fieldName
;
this
.
dataFrameIndex
=
opts
.
dataFrameIndex
;
this
.
hasMsResolution
=
this
.
isMsResolutionNeeded
();
this
.
hasMsResolution
=
this
.
isMsResolutionNeeded
();
}
}
...
...
public/app/plugins/panel/graph/data_processor.ts
View file @
0994350e
...
@@ -20,7 +20,8 @@ export class DataProcessor {
...
@@ -20,7 +20,8 @@ export class DataProcessor {
return
list
;
return
list
;
}
}
for
(
const
series
of
dataList
)
{
for
(
let
i
=
0
;
i
<
dataList
.
length
;
i
++
)
{
const
series
=
dataList
[
i
];
const
{
timeField
}
=
getTimeField
(
series
);
const
{
timeField
}
=
getTimeField
(
series
);
if
(
!
timeField
)
{
if
(
!
timeField
)
{
continue
;
continue
;
...
@@ -43,7 +44,7 @@ export class DataProcessor {
...
@@ -43,7 +44,7 @@ export class DataProcessor {
datapoints
.
push
([
field
.
values
.
get
(
r
),
timeField
.
values
.
get
(
r
)]);
datapoints
.
push
([
field
.
values
.
get
(
r
),
timeField
.
values
.
get
(
r
)]);
}
}
list
.
push
(
this
.
toTimeSeries
(
field
,
name
,
datapoints
,
list
.
length
,
range
));
list
.
push
(
this
.
toTimeSeries
(
field
,
name
,
i
,
datapoints
,
list
.
length
,
range
));
}
}
}
}
...
@@ -56,10 +57,18 @@ export class DataProcessor {
...
@@ -56,10 +57,18 @@ export class DataProcessor {
}
}
return
[
first
];
return
[
first
];
}
}
return
list
;
return
list
;
}
}
private
toTimeSeries
(
field
:
Field
,
alias
:
string
,
datapoints
:
any
[][],
index
:
number
,
range
?:
TimeRange
)
{
private
toTimeSeries
(
field
:
Field
,
alias
:
string
,
dataFrameIndex
:
number
,
datapoints
:
any
[][],
index
:
number
,
range
?:
TimeRange
)
{
const
colorIndex
=
index
%
colors
.
length
;
const
colorIndex
=
index
%
colors
.
length
;
const
color
=
this
.
panel
.
aliasColors
[
alias
]
||
colors
[
colorIndex
];
const
color
=
this
.
panel
.
aliasColors
[
alias
]
||
colors
[
colorIndex
];
...
@@ -68,6 +77,8 @@ export class DataProcessor {
...
@@ -68,6 +77,8 @@ export class DataProcessor {
alias
:
alias
,
alias
:
alias
,
color
:
getColorFromHexRgbOrName
(
color
,
config
.
theme
.
type
),
color
:
getColorFromHexRgbOrName
(
color
,
config
.
theme
.
type
),
unit
:
field
.
config
?
field
.
config
.
unit
:
undefined
,
unit
:
field
.
config
?
field
.
config
.
unit
:
undefined
,
fieldName
:
field
.
name
,
dataFrameIndex
,
});
});
if
(
datapoints
&&
datapoints
.
length
>
0
&&
range
)
{
if
(
datapoints
&&
datapoints
.
length
>
0
&&
range
)
{
...
...
public/app/plugins/panel/graph/specs/__snapshots__/data_processor.test.ts.snap
View file @
0994350e
...
@@ -9,6 +9,7 @@ Array [
...
@@ -9,6 +9,7 @@ Array [
"fillColor": "#7EB26D",
"fillColor": "#7EB26D",
},
},
"color": "#7EB26D",
"color": "#7EB26D",
"dataFrameIndex": 0,
"datapoints": Array [
"datapoints": Array [
Array [
Array [
1,
1,
...
@@ -23,6 +24,7 @@ Array [
...
@@ -23,6 +24,7 @@ Array [
1003,
1003,
],
],
],
],
"fieldName": "Value",
"hasMsResolution": false,
"hasMsResolution": false,
"id": "Value",
"id": "Value",
"label": "Value",
"label": "Value",
...
@@ -38,6 +40,7 @@ Array [
...
@@ -38,6 +40,7 @@ Array [
"fillColor": "#EAB839",
"fillColor": "#EAB839",
},
},
"color": "#EAB839",
"color": "#EAB839",
"dataFrameIndex": 1,
"datapoints": Array [
"datapoints": Array [
Array [
Array [
0.1,
0.1,
...
@@ -52,6 +55,7 @@ Array [
...
@@ -52,6 +55,7 @@ Array [
1003,
1003,
],
],
],
],
"fieldName": "v1",
"hasMsResolution": false,
"hasMsResolution": false,
"id": "table_data v1",
"id": "table_data v1",
"label": "table_data v1",
"label": "table_data v1",
...
@@ -67,6 +71,7 @@ Array [
...
@@ -67,6 +71,7 @@ Array [
"fillColor": "#6ED0E0",
"fillColor": "#6ED0E0",
},
},
"color": "#6ED0E0",
"color": "#6ED0E0",
"dataFrameIndex": 1,
"datapoints": Array [
"datapoints": Array [
Array [
Array [
1.1,
1.1,
...
@@ -81,6 +86,7 @@ Array [
...
@@ -81,6 +86,7 @@ Array [
1003,
1003,
],
],
],
],
"fieldName": "v2",
"hasMsResolution": false,
"hasMsResolution": false,
"id": "table_data v2",
"id": "table_data v2",
"label": "table_data v2",
"label": "table_data v2",
...
@@ -96,6 +102,7 @@ Array [
...
@@ -96,6 +102,7 @@ Array [
"fillColor": "#EF843C",
"fillColor": "#EF843C",
},
},
"color": "#EF843C",
"color": "#EF843C",
"dataFrameIndex": 2,
"datapoints": Array [
"datapoints": Array [
Array [
Array [
0.1,
0.1,
...
@@ -110,6 +117,7 @@ Array [
...
@@ -110,6 +117,7 @@ Array [
1003,
1003,
],
],
],
],
"fieldName": "v1",
"hasMsResolution": false,
"hasMsResolution": false,
"id": "series v1",
"id": "series v1",
"label": "series v1",
"label": "series v1",
...
@@ -125,6 +133,7 @@ Array [
...
@@ -125,6 +133,7 @@ Array [
"fillColor": "#E24D42",
"fillColor": "#E24D42",
},
},
"color": "#E24D42",
"color": "#E24D42",
"dataFrameIndex": 2,
"datapoints": Array [
"datapoints": Array [
Array [
Array [
1.1,
1.1,
...
@@ -139,6 +148,7 @@ Array [
...
@@ -139,6 +148,7 @@ Array [
1003,
1003,
],
],
],
],
"fieldName": "v2",
"hasMsResolution": false,
"hasMsResolution": false,
"id": "series v2",
"id": "series v2",
"label": "series v2",
"label": "series v2",
...
@@ -159,6 +169,7 @@ Array [
...
@@ -159,6 +169,7 @@ Array [
"fillColor": "#7EB26D",
"fillColor": "#7EB26D",
},
},
"color": "#7EB26D",
"color": "#7EB26D",
"dataFrameIndex": 0,
"datapoints": Array [
"datapoints": Array [
Array [
Array [
1,
1,
...
@@ -221,6 +232,7 @@ Array [
...
@@ -221,6 +232,7 @@ Array [
1003,
1003,
],
],
],
],
"fieldName": "Value",
"hasMsResolution": false,
"hasMsResolution": false,
"id": "Value",
"id": "Value",
"label": "Value",
"label": "Value",
...
...
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