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
3f64d61f
Commit
3f64d61f
authored
Feb 07, 2019
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Add util to convert snapshotData to PanelData
parent
c4b2dcef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletions
+18
-1
public/app/features/dashboard/utils/panel.ts
+18
-1
No files found.
public/app/features/dashboard/utils/panel.ts
View file @
3f64d61f
...
...
@@ -4,7 +4,8 @@ import store from 'app/core/store';
// Models
import
{
DashboardModel
}
from
'app/features/dashboard/state/DashboardModel'
;
import
{
PanelModel
}
from
'app/features/dashboard/state/PanelModel'
;
import
{
TimeRange
}
from
'@grafana/ui'
;
import
{
PanelData
,
TimeRange
,
TimeSeries
}
from
'@grafana/ui'
;
import
{
TableData
}
from
'@grafana/ui/src'
;
// Utils
import
{
isString
as
_isString
}
from
'lodash'
;
...
...
@@ -168,3 +169,19 @@ export function getResolution(panel: PanelModel): number {
return
panel
.
maxDataPoints
?
panel
.
maxDataPoints
:
Math
.
ceil
(
width
*
(
panel
.
gridPos
.
w
/
24
));
}
const
isTimeSeries
=
(
data
:
any
):
data
is
TimeSeries
=>
data
&&
data
.
hasOwnProperty
(
'datapoints'
);
const
isTableData
=
(
data
:
any
):
data
is
TableData
=>
data
&&
data
.
hasOwnProperty
(
'columns'
);
export
const
snapshotDataToPanelData
=
(
panel
:
PanelModel
):
PanelData
=>
{
const
snapshotData
=
panel
.
snapshotData
;
if
(
isTimeSeries
(
snapshotData
[
0
]))
{
return
{
timeSeries
:
snapshotData
}
as
PanelData
;
}
else
if
(
isTableData
(
snapshotData
[
0
]))
{
return
{
tableData
:
snapshotData
[
0
]
}
as
PanelData
;
}
throw
new
Error
(
'snapshotData is invalid:'
+
snapshotData
.
toString
());
};
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