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
0fd92ef6
Commit
0fd92ef6
authored
Dec 17, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring react graph
parent
1ac81c3a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
89 deletions
+105
-89
public/app/plugins/panel/graph2/GraphOptions.tsx
+54
-0
public/app/plugins/panel/graph2/GraphPanel.tsx
+43
-0
public/app/plugins/panel/graph2/module.tsx
+3
-89
public/app/plugins/panel/graph2/types.ts
+5
-0
No files found.
public/app/plugins/panel/graph2/GraphOptions.tsx
0 → 100644
View file @
0fd92ef6
//// Libraries
import
_
from
'lodash'
;
import
React
,
{
PureComponent
}
from
'react'
;
// Components
import
{
Switch
}
from
'app/core/components/Switch/Switch'
;
// Types
import
{
PanelOptionsProps
}
from
'app/types'
;
import
{
Options
}
from
'./types'
;
export
class
GraphOptions
extends
PureComponent
<
PanelOptionsProps
<
Options
>>
{
onToggleLines
=
()
=>
{
this
.
props
.
onChange
({
...
this
.
props
.
options
,
showLines
:
!
this
.
props
.
options
.
showLines
});
};
onToggleBars
=
()
=>
{
this
.
props
.
onChange
({
...
this
.
props
.
options
,
showBars
:
!
this
.
props
.
options
.
showBars
});
};
onTogglePoints
=
()
=>
{
this
.
props
.
onChange
({
...
this
.
props
.
options
,
showPoints
:
!
this
.
props
.
options
.
showPoints
});
};
render
()
{
const
{
showBars
,
showPoints
,
showLines
}
=
this
.
props
.
options
;
return
(
<
div
>
<
div
className=
"form-option-box"
>
<
div
className=
"form-option-box__header"
>
Display Options
</
div
>
<
div
className=
"section gf-form-group"
>
<
h5
className=
"section-heading"
>
Draw Modes
</
h5
>
<
Switch
label=
"Lines"
labelClass=
"width-5"
checked=
{
showLines
}
onChange=
{
this
.
onToggleLines
}
/>
<
Switch
label=
"Bars"
labelClass=
"width-5"
checked=
{
showBars
}
onChange=
{
this
.
onToggleBars
}
/>
<
Switch
label=
"Points"
labelClass=
"width-5"
checked=
{
showPoints
}
onChange=
{
this
.
onTogglePoints
}
/>
</
div
>
<
div
className=
"section gf-form-group"
>
<
h5
className=
"section-heading"
>
Test Options
</
h5
>
<
Switch
label=
"Lines"
labelClass=
"width-5"
checked=
{
showLines
}
onChange=
{
this
.
onToggleLines
}
/>
<
Switch
label=
"Bars"
labelClass=
"width-5"
checked=
{
showBars
}
onChange=
{
this
.
onToggleBars
}
/>
<
Switch
label=
"Points"
labelClass=
"width-5"
checked=
{
showPoints
}
onChange=
{
this
.
onTogglePoints
}
/>
</
div
>
</
div
>
<
div
className=
"form-option-box"
>
<
div
className=
"form-option-box__header"
>
Axes
</
div
>
</
div
>
<
div
className=
"form-option-box"
>
<
div
className=
"form-option-box__header"
>
Thresholds
</
div
>
</
div
>
</
div
>
);
}
}
public/app/plugins/panel/graph2/GraphPanel.tsx
0 → 100644
View file @
0fd92ef6
// Libraries
import
_
from
'lodash'
;
import
React
,
{
PureComponent
}
from
'react'
;
// Components
import
Graph
from
'app/viz/Graph'
;
// Services & Utils
import
{
getTimeSeriesVMs
}
from
'app/viz/state/timeSeries'
;
// Types
import
{
PanelProps
,
NullValueMode
}
from
'app/types'
;
import
{
Options
}
from
'./types'
;
interface
Props
extends
PanelProps
<
Options
>
{}
export
class
GraphPanel
extends
PureComponent
<
Props
>
{
constructor
(
props
)
{
super
(
props
);
}
render
()
{
const
{
timeSeries
,
timeRange
,
width
,
height
}
=
this
.
props
;
const
{
showLines
,
showBars
,
showPoints
}
=
this
.
props
.
options
;
const
vmSeries
=
getTimeSeriesVMs
({
timeSeries
:
timeSeries
,
nullValueMode
:
NullValueMode
.
Ignore
,
});
return
(
<
Graph
timeSeries=
{
vmSeries
}
timeRange=
{
timeRange
}
showLines=
{
showLines
}
showPoints=
{
showPoints
}
showBars=
{
showBars
}
width=
{
width
}
height=
{
height
}
/>
);
}
}
public/app/plugins/panel/graph2/module.tsx
View file @
0fd92ef6
import
_
from
'lodash
'
;
import
React
,
{
PureComponent
}
from
'react
'
;
import
{
GraphPanel
}
from
'./GraphPanel
'
;
import
{
GraphOptions
}
from
'./GraphOptions
'
;
import
Graph
from
'app/viz/Graph'
;
import
{
Switch
}
from
'app/core/components/Switch/Switch'
;
import
{
getTimeSeriesVMs
}
from
'app/viz/state/timeSeries'
;
import
{
PanelProps
,
PanelOptionsProps
,
NullValueMode
}
from
'app/types'
;
interface
Options
{
showBars
:
boolean
;
showLines
:
boolean
;
showPoints
:
boolean
;
}
interface
Props
extends
PanelProps
<
Options
>
{}
export
class
Graph2
extends
PureComponent
<
Props
>
{
constructor
(
props
)
{
super
(
props
);
}
render
()
{
const
{
timeSeries
,
timeRange
,
width
,
height
}
=
this
.
props
;
const
{
showLines
,
showBars
,
showPoints
}
=
this
.
props
.
options
;
const
vmSeries
=
getTimeSeriesVMs
({
timeSeries
:
timeSeries
,
nullValueMode
:
NullValueMode
.
Ignore
,
});
return
(
<
Graph
timeSeries=
{
vmSeries
}
timeRange=
{
timeRange
}
showLines=
{
showLines
}
showPoints=
{
showPoints
}
showBars=
{
showBars
}
width=
{
width
}
height=
{
height
}
/>
);
}
}
export
class
GraphOptions
extends
PureComponent
<
PanelOptionsProps
<
Options
>>
{
onToggleLines
=
()
=>
{
this
.
props
.
onChange
({
...
this
.
props
.
options
,
showLines
:
!
this
.
props
.
options
.
showLines
});
};
onToggleBars
=
()
=>
{
this
.
props
.
onChange
({
...
this
.
props
.
options
,
showBars
:
!
this
.
props
.
options
.
showBars
});
};
onTogglePoints
=
()
=>
{
this
.
props
.
onChange
({
...
this
.
props
.
options
,
showPoints
:
!
this
.
props
.
options
.
showPoints
});
};
render
()
{
const
{
showBars
,
showPoints
,
showLines
}
=
this
.
props
.
options
;
return
(
<
div
>
<
div
className=
"form-option-box"
>
<
div
className=
"form-option-box__header"
>
Display Options
</
div
>
<
div
className=
"section gf-form-group"
>
<
h5
className=
"section-heading"
>
Draw Modes
</
h5
>
<
Switch
label=
"Lines"
labelClass=
"width-5"
checked=
{
showLines
}
onChange=
{
this
.
onToggleLines
}
/>
<
Switch
label=
"Bars"
labelClass=
"width-5"
checked=
{
showBars
}
onChange=
{
this
.
onToggleBars
}
/>
<
Switch
label=
"Points"
labelClass=
"width-5"
checked=
{
showPoints
}
onChange=
{
this
.
onTogglePoints
}
/>
</
div
>
<
div
className=
"section gf-form-group"
>
<
h5
className=
"section-heading"
>
Test Options
</
h5
>
<
Switch
label=
"Lines"
labelClass=
"width-5"
checked=
{
showLines
}
onChange=
{
this
.
onToggleLines
}
/>
<
Switch
label=
"Bars"
labelClass=
"width-5"
checked=
{
showBars
}
onChange=
{
this
.
onToggleBars
}
/>
<
Switch
label=
"Points"
labelClass=
"width-5"
checked=
{
showPoints
}
onChange=
{
this
.
onTogglePoints
}
/>
</
div
>
</
div
>
<
div
className=
"form-option-box"
>
<
div
className=
"form-option-box__header"
>
Axes
</
div
>
</
div
>
<
div
className=
"form-option-box"
>
<
div
className=
"form-option-box__header"
>
Thresholds
</
div
>
</
div
>
</
div
>
);
}
}
export
{
Graph2
as
Panel
,
GraphOptions
as
PanelOptions
};
export
{
GraphPanel
as
Panel
,
GraphOptions
as
PanelOptions
};
public/app/plugins/panel/graph2/types.ts
0 → 100644
View file @
0fd92ef6
export
interface
Options
{
showBars
:
boolean
;
showLines
:
boolean
;
showPoints
:
boolean
;
}
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