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
f72e7517
Commit
f72e7517
authored
Nov 19, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
picker and functionaliy
parent
e21a140f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
30 deletions
+61
-30
public/app/plugins/panel/gauge/GaugeOptions.tsx
+0
-16
public/app/plugins/panel/gauge/module.tsx
+49
-4
public/app/viz/Gauge.tsx
+12
-10
No files found.
public/app/plugins/panel/gauge/GaugeOptions.tsx
deleted
100644 → 0
View file @
e21a140f
import
React
,
{
PureComponent
}
from
'react'
;
import
{
PanelOptionsProps
}
from
'app/types'
;
interface
Props
{}
export
class
GaugeOptions
extends
PureComponent
<
PanelOptionsProps
<
Props
>>
{
render
()
{
return
(
<
div
>
<
div
className=
"section gf-form-group"
>
<
h5
className=
"page-heading"
>
Draw Modes
</
h5
>
</
div
>
</
div
>
);
}
}
public/app/plugins/panel/gauge/module.tsx
View file @
f72e7517
import
React
,
{
PureComponent
}
from
'react'
;
import
Gauge
from
'app/viz/Gauge'
;
import
{
NullValueMode
,
PanelProps
}
from
'app/types'
;
import
{
NullValueMode
,
Panel
OptionsProps
,
Panel
Props
}
from
'app/types'
;
import
{
getTimeSeriesVMs
}
from
'app/viz/state/timeSeries'
;
import
{
GaugeOptions
}
from
'./GaugeOptions'
;
import
{
Label
}
from
'../../../core/components/Label/Label'
;
import
SimplePicker
from
'../../../core/components/Picker/SimplePicker'
;
export
interface
Options
{}
export
interface
Options
{
stat
:
{
value
:
string
;
text
:
string
};
}
interface
Props
extends
PanelProps
<
Options
>
{}
const
statOptions
=
[
{
value
:
'min'
,
text
:
'Min'
},
{
value
:
'max'
,
text
:
'Max'
},
{
value
:
'avg'
,
text
:
'Average'
},
{
value
:
'current'
,
text
:
'Current'
},
{
value
:
'total'
,
text
:
'Total'
},
{
value
:
'name'
,
text
:
'Name'
},
{
value
:
'first'
,
text
:
'First'
},
{
value
:
'delta'
,
text
:
'Delta'
},
{
value
:
'diff'
,
text
:
'Difference'
},
{
value
:
'range'
,
text
:
'Range'
},
{
value
:
'last_time'
,
text
:
'Time of last point'
},
];
export
class
GaugePanel
extends
PureComponent
<
Props
>
{
render
()
{
const
{
timeSeries
,
width
,
height
}
=
this
.
props
;
...
...
@@ -17,8 +34,36 @@ export class GaugePanel extends PureComponent<Props> {
nullValueMode
:
NullValueMode
.
Ignore
,
});
return
<
Gauge
timeSeries=
{
vmSeries
}
{
...
this
.
props
.
options
}
width=
{
width
}
height=
{
height
}
/>;
}
}
class
GaugeOptions
extends
PureComponent
<
PanelOptionsProps
<
Options
>>
{
onStatChange
=
value
=>
{
this
.
props
.
onChange
({
...
this
.
props
.
options
,
stat
:
value
});
};
render
()
{
const
{
stat
}
=
this
.
props
.
options
;
return
(
<
Gauge
maxValue=
{
100
}
minValue=
{
0
}
timeSeries=
{
vmSeries
}
thresholds=
{
[
0
,
100
]
}
height=
{
height
}
width=
{
width
}
/>
<
div
>
<
div
className=
"section gf-form-group"
>
<
h5
className=
"page-heading"
>
Value
</
h5
>
<
div
className=
"gf-form-inline"
>
<
Label
width=
{
5
}
>
Stat
</
Label
>
<
SimplePicker
defaultValue=
{
statOptions
.
find
(
option
=>
option
.
value
===
stat
.
value
)
}
width=
{
11
}
options=
{
statOptions
}
getOptionLabel=
{
i
=>
i
.
text
}
getOptionValue=
{
i
=>
i
.
value
}
onSelected=
{
this
.
onStatChange
}
value=
{
stat
}
/>
</
div
>
</
div
>
</
div
>
);
}
}
...
...
public/app/viz/Gauge.tsx
View file @
f72e7517
...
...
@@ -5,13 +5,14 @@ import config from '../core/config';
interface
Props
{
timeSeries
:
TimeSeriesVMs
;
minValue
:
number
;
maxValue
:
number
;
minValue
?
:
number
;
maxValue
?
:
number
;
showThresholdMarkers
?:
boolean
;
thresholds
?:
number
[];
showThresholdLables
?:
boolean
;
width
:
number
;
height
:
number
;
stat
?:
{
value
:
string
;
text
:
string
};
}
const
colors
=
[
'rgba(50, 172, 45, 0.97)'
,
'rgba(237, 129, 40, 0.89)'
,
'rgba(245, 54, 54, 0.9)'
];
...
...
@@ -25,7 +26,7 @@ export class Gauge extends PureComponent<Props> {
maxValue
:
100
,
showThresholdMarkers
:
true
,
showThresholdLables
:
false
,
thresholds
:
[],
thresholds
:
[
0
,
100
],
};
componentDidMount
()
{
...
...
@@ -38,16 +39,19 @@ export class Gauge extends PureComponent<Props> {
draw
()
{
const
{
timeSeries
,
maxValue
,
minValue
,
showThresholdLables
,
showThresholdMarkers
,
timeSeries
,
thresholds
,
width
,
height
,
stat
,
}
=
this
.
props
;
console
.
log
(
stat
);
const
dimension
=
Math
.
min
(
width
,
height
*
1.3
);
const
backgroundColor
=
config
.
bootData
.
user
.
lightTheme
?
'rgb(230,230,230)'
:
'rgb(38,38,38)'
;
const
fontColor
=
config
.
bootData
.
user
.
lightTheme
?
'rgb(38,38,38)'
:
'rgb(230,230,230)'
;
...
...
@@ -57,13 +61,11 @@ export class Gauge extends PureComponent<Props> {
const
thresholdMarkersWidth
=
gaugeWidth
/
5
;
const
thresholdLabelFontSize
=
fontSize
/
2.5
;
const
formattedThresholds
=
[];
thresholds
.
forEach
((
threshold
,
index
)
=>
{
formattedThresholds
.
push
({
const
formattedThresholds
=
thresholds
.
map
((
threshold
,
index
)
=>
{
return
{
value
:
threshold
,
color
:
colors
[
index
],
}
)
;
};
});
const
options
=
{
...
...
@@ -94,7 +96,7 @@ export class Gauge extends PureComponent<Props> {
value
:
{
color
:
fontColor
,
formatter
:
()
=>
{
return
Math
.
round
(
timeSeries
[
0
].
stats
.
avg
);
return
Math
.
round
(
timeSeries
[
0
].
stats
[
stat
.
value
]
);
},
font
:
{
size
:
fontSize
,
...
...
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