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
Show 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[]) {
return
{
datamin
,
datamax
};
}
/**
* @deprecated: This class should not be used in new panels
*
* Use DataFrame and helpers instead
*/
export
default
class
TimeSeries
{
datapoints
:
any
;
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
;
alias
:
string
;
aliasEscaped
:
string
;
...
...
@@ -110,6 +122,8 @@ export default class TimeSeries {
this
.
stats
=
{};
this
.
legend
=
true
;
this
.
unit
=
opts
.
unit
;
this
.
fieldName
=
opts
.
fieldName
;
this
.
dataFrameIndex
=
opts
.
dataFrameIndex
;
this
.
hasMsResolution
=
this
.
isMsResolutionNeeded
();
}
...
...
public/app/plugins/panel/graph/data_processor.ts
View file @
0994350e
...
...
@@ -20,7 +20,8 @@ export class DataProcessor {
return
list
;
}
for
(
const
series
of
dataList
)
{
for
(
let
i
=
0
;
i
<
dataList
.
length
;
i
++
)
{
const
series
=
dataList
[
i
];
const
{
timeField
}
=
getTimeField
(
series
);
if
(
!
timeField
)
{
continue
;
...
...
@@ -43,7 +44,7 @@ export class DataProcessor {
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 {
}
return
[
first
];
}
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
color
=
this
.
panel
.
aliasColors
[
alias
]
||
colors
[
colorIndex
];
...
...
@@ -68,6 +77,8 @@ export class DataProcessor {
alias
:
alias
,
color
:
getColorFromHexRgbOrName
(
color
,
config
.
theme
.
type
),
unit
:
field
.
config
?
field
.
config
.
unit
:
undefined
,
fieldName
:
field
.
name
,
dataFrameIndex
,
});
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 [
"fillColor": "#7EB26D",
},
"color": "#7EB26D",
"dataFrameIndex": 0,
"datapoints": Array [
Array [
1,
...
...
@@ -23,6 +24,7 @@ Array [
1003,
],
],
"fieldName": "Value",
"hasMsResolution": false,
"id": "Value",
"label": "Value",
...
...
@@ -38,6 +40,7 @@ Array [
"fillColor": "#EAB839",
},
"color": "#EAB839",
"dataFrameIndex": 1,
"datapoints": Array [
Array [
0.1,
...
...
@@ -52,6 +55,7 @@ Array [
1003,
],
],
"fieldName": "v1",
"hasMsResolution": false,
"id": "table_data v1",
"label": "table_data v1",
...
...
@@ -67,6 +71,7 @@ Array [
"fillColor": "#6ED0E0",
},
"color": "#6ED0E0",
"dataFrameIndex": 1,
"datapoints": Array [
Array [
1.1,
...
...
@@ -81,6 +86,7 @@ Array [
1003,
],
],
"fieldName": "v2",
"hasMsResolution": false,
"id": "table_data v2",
"label": "table_data v2",
...
...
@@ -96,6 +102,7 @@ Array [
"fillColor": "#EF843C",
},
"color": "#EF843C",
"dataFrameIndex": 2,
"datapoints": Array [
Array [
0.1,
...
...
@@ -110,6 +117,7 @@ Array [
1003,
],
],
"fieldName": "v1",
"hasMsResolution": false,
"id": "series v1",
"label": "series v1",
...
...
@@ -125,6 +133,7 @@ Array [
"fillColor": "#E24D42",
},
"color": "#E24D42",
"dataFrameIndex": 2,
"datapoints": Array [
Array [
1.1,
...
...
@@ -139,6 +148,7 @@ Array [
1003,
],
],
"fieldName": "v2",
"hasMsResolution": false,
"id": "series v2",
"label": "series v2",
...
...
@@ -159,6 +169,7 @@ Array [
"fillColor": "#7EB26D",
},
"color": "#7EB26D",
"dataFrameIndex": 0,
"datapoints": Array [
Array [
1,
...
...
@@ -221,6 +232,7 @@ Array [
1003,
],
],
"fieldName": "Value",
"hasMsResolution": false,
"id": "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