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
8bf57359
Commit
8bf57359
authored
Mar 07, 2019
by
ryan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't require x & y columns for timeSeries
parent
abf015ac
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
24 deletions
+18
-24
packages/grafana-ui/src/utils/processTimeSeries.ts
+17
-2
public/app/features/dashboard/dashgrid/DataPanel.tsx
+1
-5
public/app/plugins/panel/gauge/GaugePanel.tsx
+0
-12
public/app/plugins/panel/graph2/GraphPanel.tsx
+0
-5
No files found.
packages/grafana-ui/src/utils/processTimeSeries.ts
View file @
8bf57359
...
...
@@ -8,13 +8,28 @@ import { TimeSeriesVMs, NullValueMode, TimeSeriesValue, TableData } from '../typ
interface
Options
{
data
:
TableData
[];
xColumn
:
number
;
// Time
yColumn
:
number
;
// Value
xColumn
?
:
number
;
// Time
yColumn
?
:
number
;
// Value
nullValueMode
:
NullValueMode
;
}
export
function
processTimeSeries
({
data
,
xColumn
,
yColumn
,
nullValueMode
}:
Options
):
TimeSeriesVMs
{
const
vmSeries
=
data
.
map
((
item
,
index
)
=>
{
if
(
!
isNumber
(
xColumn
))
{
xColumn
=
1
;
// Default timeseries colum. TODO, find first time field!
}
if
(
!
isNumber
(
yColumn
))
{
yColumn
=
0
;
// TODO, find first non-time field
}
// TODO? either % or throw error?
if
(
xColumn
>=
item
.
columns
.
length
)
{
throw
new
Error
(
'invalid colum: '
+
xColumn
);
}
if
(
yColumn
>=
item
.
columns
.
length
)
{
throw
new
Error
(
'invalid colum: '
+
yColumn
);
}
const
colorIndex
=
index
%
colors
.
length
;
const
label
=
item
.
columns
[
yColumn
].
text
;
const
result
=
[];
...
...
public/app/features/dashboard/dashgrid/DataPanel.tsx
View file @
8bf57359
...
...
@@ -145,12 +145,10 @@ export class DataPanel extends Component<Props, State> {
onDataResponse
(
resp
);
}
const
data
=
toTableData
(
resp
.
data
);
console
.
log
(
'Converted:'
,
data
);
this
.
setState
({
loading
:
LoadingState
.
Done
,
response
:
resp
,
data
,
data
:
toTableData
(
resp
.
data
)
,
isFirstLoad
:
false
,
});
}
catch
(
err
)
{
...
...
@@ -190,8 +188,6 @@ export class DataPanel extends Component<Props, State> {
);
}
console
.
log
(
'RENDER'
,
data
);
return
(
<>
{
loading
===
LoadingState
.
Loading
&&
this
.
renderLoadingState
()
}
...
...
public/app/plugins/panel/gauge/GaugePanel.tsx
View file @
8bf57359
...
...
@@ -22,12 +22,9 @@ export class GaugePanel extends Component<Props, State> {
this
.
state
=
{
value
:
this
.
findValue
(
props
),
};
console
.
log
(
'CONSTRUCTOR!'
,
this
.
props
.
data
);
}
componentDidUpdate
(
prevProps
:
Props
)
{
console
.
log
(
'UPDATE'
,
this
.
props
.
data
);
if
(
this
.
props
.
data
!==
prevProps
.
data
)
{
this
.
setState
({
value
:
this
.
findValue
(
this
.
props
)
});
}
...
...
@@ -37,21 +34,12 @@ export class GaugePanel extends Component<Props, State> {
const
{
data
,
options
}
=
props
;
const
{
valueOptions
}
=
options
;
console
.
log
(
'FIND VALUE'
,
data
);
if
(
data
)
{
// For now, assume timeseries defaults
const
xColumn
=
1
;
// time
const
yColumn
=
0
;
// value
const
vmSeries
=
processTimeSeries
({
data
,
xColumn
,
yColumn
,
nullValueMode
:
NullValueMode
.
Null
,
});
console
.
log
(
'GOT'
,
vmSeries
);
if
(
vmSeries
[
0
])
{
return
vmSeries
[
0
].
stats
[
valueOptions
.
stat
];
}
...
...
public/app/plugins/panel/graph2/GraphPanel.tsx
View file @
8bf57359
...
...
@@ -21,13 +21,8 @@ export class GraphPanel extends PureComponent<Props> {
let
vmSeries
:
TimeSeriesVMs
;
if
(
data
)
{
// For now, assume timeseries defaults
const
xColumn
=
1
;
// time
const
yColumn
=
0
;
// value
vmSeries
=
processTimeSeries
({
data
,
xColumn
,
yColumn
,
nullValueMode
:
NullValueMode
.
Ignore
,
});
}
...
...
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