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
a28c25a2
Commit
a28c25a2
authored
Oct 15, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
progress on react time series infra
parent
9adad76f
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
27 deletions
+48
-27
public/app/features/dashboard/dashgrid/PanelChrome.tsx
+1
-1
public/app/plugins/panel/graph2/module.tsx
+8
-4
public/app/types/index.ts
+4
-2
public/app/types/series.ts
+8
-2
public/app/viz/Graph.tsx
+6
-9
public/app/viz/state/getTimeSeriesViewModel.ts
+0
-9
public/app/viz/state/timeSeries.ts
+21
-0
No files found.
public/app/features/dashboard/dashgrid/PanelChrome.tsx
View file @
a28c25a2
...
@@ -74,7 +74,7 @@ export class PanelChrome extends PureComponent<Props, State> {
...
@@ -74,7 +74,7 @@ export class PanelChrome extends PureComponent<Props, State> {
refreshCounter=
{
refreshCounter
}
refreshCounter=
{
refreshCounter
}
>
>
{
({
loading
,
timeSeries
})
=>
{
{
({
loading
,
timeSeries
})
=>
{
return
<
PanelComponent
loading=
{
loading
}
timeSeries=
{
timeSeries
}
/>;
return
<
PanelComponent
loading=
{
loading
}
timeSeries=
{
timeSeries
}
timeRange=
{
timeRange
}
/>;
}
}
}
}
</
DataPanel
>
</
DataPanel
>
</
div
>
</
div
>
...
...
public/app/plugins/panel/graph2/module.tsx
View file @
a28c25a2
...
@@ -3,7 +3,10 @@ import _ from 'lodash';
...
@@ -3,7 +3,10 @@ import _ from 'lodash';
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
// Components
// Components
import
{
Graph
}
from
'app/viz/Graph'
;
import
Graph
from
'app/viz/Graph'
;
// Utils
import
{
getTimeSeriesVMs
}
from
'app/viz/state/timeSeries'
;
// Types
// Types
import
{
PanelProps
}
from
'app/types'
;
import
{
PanelProps
}
from
'app/types'
;
...
@@ -22,10 +25,11 @@ export class Graph2 extends PureComponent<Props> {
...
@@ -22,10 +25,11 @@ export class Graph2 extends PureComponent<Props> {
}
}
render
()
{
render
()
{
const
{
timeSeries
}
=
this
.
props
;
const
{
timeSeries
,
timeRange
}
=
this
.
props
;
let
index
=
0
;
const
viewModels
=
getTimeSeriesVMs
({
timeSeries
});
console
.
log
(
viewModels
);
return
<
Graph
timeSeries=
{
timeSeries
}
/>;
return
<
Graph
timeSeries=
{
viewModels
}
timeRange=
{
timeRange
}
/>;
}
}
}
}
...
...
public/app/types/index.ts
View file @
a28c25a2
...
@@ -13,10 +13,11 @@ import {
...
@@ -13,10 +13,11 @@ import {
TimeRange
,
TimeRange
,
LoadingState
,
LoadingState
,
TimeSeries
,
TimeSeries
,
TimeSeriesVM
,
TimeSeriesVMs
,
DataQuery
,
DataQuery
,
DataQueryResponse
,
DataQueryResponse
,
DataQueryOptions
,
DataQueryOptions
,
TimeSeriesViewModel
,
}
from
'./series'
;
}
from
'./series'
;
import
{
PanelProps
}
from
'./panel'
;
import
{
PanelProps
}
from
'./panel'
;
...
@@ -59,7 +60,8 @@ export {
...
@@ -59,7 +60,8 @@ export {
LoadingState
,
LoadingState
,
PanelProps
,
PanelProps
,
TimeSeries
,
TimeSeries
,
TimeSeriesViewModel
,
TimeSeriesVM
,
TimeSeriesVMs
,
DataQuery
,
DataQuery
,
DataQueryResponse
,
DataQueryResponse
,
DataQueryOptions
,
DataQueryOptions
,
...
...
public/app/types/series.ts
View file @
a28c25a2
...
@@ -28,10 +28,16 @@ export interface TimeSeries {
...
@@ -28,10 +28,16 @@ export interface TimeSeries {
unit
?:
string
;
unit
?:
string
;
}
}
export
interface
TimeSeriesViewModel
{
/** View model projection of a time series */
export
interface
TimeSeriesVM
{
label
:
string
;
label
:
string
;
color
:
string
;
color
:
string
;
data
:
number
[][];
data
:
TimeSeriesValue
[][];
}
/** View model projection of many time series */
export
interface
TimeSeriesVMs
{
[
index
:
number
]:
TimeSeriesVM
;
}
}
export
interface
DataQueryResponse
{
export
interface
DataQueryResponse
{
...
...
public/app/viz/Graph.tsx
View file @
a28c25a2
...
@@ -6,8 +6,7 @@ import 'vendor/flot/jquery.flot';
...
@@ -6,8 +6,7 @@ import 'vendor/flot/jquery.flot';
import
'vendor/flot/jquery.flot.time'
;
import
'vendor/flot/jquery.flot.time'
;
// Types
// Types
import
TimeSeries
from
'app/core/time_series2'
;
import
{
TimeRange
,
TimeSeriesVMs
}
from
'app/types'
;
import
{
TimeRange
}
from
'app/types'
;
// Copied from graph.ts
// Copied from graph.ts
function
time_format
(
ticks
,
min
,
max
)
{
function
time_format
(
ticks
,
min
,
max
)
{
...
@@ -60,7 +59,7 @@ const FLOT_OPTIONS = {
...
@@ -60,7 +59,7 @@ const FLOT_OPTIONS = {
};
};
interface
GraphProps
{
interface
GraphProps
{
timeSeries
:
TimeSeries
[]
;
timeSeries
:
TimeSeries
VMs
;
timeRange
:
TimeRange
;
timeRange
:
TimeRange
;
size
?:
{
width
:
number
;
height
:
number
};
size
?:
{
width
:
number
;
height
:
number
};
}
}
...
@@ -85,11 +84,9 @@ export class Graph extends PureComponent<GraphProps> {
...
@@ -85,11 +84,9 @@ export class Graph extends PureComponent<GraphProps> {
draw
()
{
draw
()
{
const
{
size
,
timeSeries
,
timeRange
}
=
this
.
props
;
const
{
size
,
timeSeries
,
timeRange
}
=
this
.
props
;
const
data
=
timeSeries
.
map
((
ts
:
TimeSeries
)
=>
({
if
(
!
size
)
{
color
:
ts
.
color
,
return
;
label
:
ts
.
label
,
}
data
:
ts
.
getFlotPairs
(
'null'
),
}));
const
ticks
=
(
size
.
width
||
0
)
/
100
;
const
ticks
=
(
size
.
width
||
0
)
/
100
;
const
min
=
timeRange
.
from
.
valueOf
();
const
min
=
timeRange
.
from
.
valueOf
();
...
@@ -111,7 +108,7 @@ export class Graph extends PureComponent<GraphProps> {
...
@@ -111,7 +108,7 @@ export class Graph extends PureComponent<GraphProps> {
...
dynamicOptions
,
...
dynamicOptions
,
};
};
$
.
plot
(
this
.
element
,
data
,
options
);
$
.
plot
(
this
.
element
,
timeSeries
,
options
);
}
}
render
()
{
render
()
{
...
...
public/app/viz/state/getTimeSeriesViewModel.ts
deleted
100644 → 0
View file @
9adad76f
import
colors
from
'app/core/utils/colors'
;
import
{
TimeSeries
,
TimeSeriesViewModel
}
from
'app/types'
;
interface
Options
{
ts
:
TimeSeries
;
seriesIndex
:
number
;
}
export
function
getTimeSeriesViewModel
(
ts
:
TimeSeries
):
TimeSeriesViewModel
{}
public/app/viz/state/timeSeries.ts
0 → 100644
View file @
a28c25a2
import
colors
from
'app/core/utils/colors'
;
import
{
TimeSeries
,
TimeSeriesVMs
}
from
'app/types'
;
interface
Options
{
timeSeries
:
TimeSeries
[];
}
export
function
getTimeSeriesVMs
({
timeSeries
}:
Options
):
TimeSeriesVMs
{
const
vmSeries
=
timeSeries
.
map
((
item
,
index
)
=>
{
const
colorIndex
=
index
%
colors
.
length
;
const
label
=
item
.
target
;
return
{
data
:
item
.
datapoints
,
label
:
label
,
color
:
colors
[
colorIndex
],
};
});
return
vmSeries
;
}
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