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
3662f1c0
Commit
3662f1c0
authored
Dec 14, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getting closer with no thresholds
parent
234095e6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
21 deletions
+22
-21
public/app/plugins/panel/gauge/Thresholds.tsx
+3
-1
public/app/plugins/panel/gauge/module.tsx
+1
-4
public/app/types/panel.ts
+2
-3
public/app/viz/Gauge.tsx
+16
-13
No files found.
public/app/plugins/panel/gauge/Thresholds.tsx
View file @
3662f1c0
...
@@ -29,8 +29,10 @@ export default class Thresholds extends PureComponent<OptionModuleProps, State>
...
@@ -29,8 +29,10 @@ export default class Thresholds extends PureComponent<OptionModuleProps, State>
return
threshold
;
return
threshold
;
});
});
// Setting value to a value between the
new threshold.
// Setting value to a value between the
previous thresholds
const
value
=
newThresholds
[
index
].
value
-
(
newThresholds
[
index
].
value
-
newThresholds
[
index
-
1
].
value
)
/
2
;
const
value
=
newThresholds
[
index
].
value
-
(
newThresholds
[
index
].
value
-
newThresholds
[
index
-
1
].
value
)
/
2
;
// Set a color that lies between the previous thresholds
const
color
=
tinycolor
.
mix
(
thresholds
[
index
-
1
].
color
,
thresholds
[
index
].
color
,
50
).
toRgbString
();
const
color
=
tinycolor
.
mix
(
thresholds
[
index
-
1
].
color
,
thresholds
[
index
].
color
,
50
).
toRgbString
();
this
.
setState
(
this
.
setState
(
...
...
public/app/plugins/panel/gauge/module.tsx
View file @
3662f1c0
...
@@ -48,10 +48,7 @@ export const defaultProps = {
...
@@ -48,10 +48,7 @@ export const defaultProps = {
stat
:
''
,
stat
:
''
,
unit
:
''
,
unit
:
''
,
mappings
:
[],
mappings
:
[],
thresholds
:
[
thresholds
:
[],
{
index
:
0
,
value
:
0
,
color
:
BasicGaugeColor
.
Green
,
label
:
'Min'
,
canRemove
:
false
},
{
index
:
1
,
value
:
100
,
color
:
BasicGaugeColor
.
Red
,
label
:
'Max'
,
canRemove
:
false
},
],
},
},
};
};
...
...
public/app/types/panel.ts
View file @
3662f1c0
...
@@ -43,9 +43,8 @@ export enum MappingType {
...
@@ -43,9 +43,8 @@ export enum MappingType {
}
}
export
enum
BasicGaugeColor
{
export
enum
BasicGaugeColor
{
Green
=
'rgba(50, 172, 45, 0.97)'
,
Green
=
'lightgreen'
,
Orange
=
'rgba(237, 129, 40, 0.89)'
,
Red
=
'red'
,
Red
=
'rgb(212, 74, 58)'
,
}
}
interface
BaseMap
{
interface
BaseMap
{
...
...
public/app/viz/Gauge.tsx
View file @
3662f1c0
...
@@ -34,7 +34,7 @@ export class Gauge extends PureComponent<Props> {
...
@@ -34,7 +34,7 @@ export class Gauge extends PureComponent<Props> {
showThresholdMarkers
:
true
,
showThresholdMarkers
:
true
,
showThresholdLabels
:
false
,
showThresholdLabels
:
false
,
suffix
:
''
,
suffix
:
''
,
thresholds
:
[
{
value
:
0
,
color
:
BasicGaugeColor
.
Green
},
{
value
:
100
,
color
:
BasicGaugeColor
.
Red
}
],
thresholds
:
[],
unit
:
'none'
,
unit
:
'none'
,
stat
:
'avg'
,
stat
:
'avg'
,
};
};
...
@@ -136,13 +136,20 @@ export class Gauge extends PureComponent<Props> {
...
@@ -136,13 +136,20 @@ export class Gauge extends PureComponent<Props> {
const
thresholdMarkersWidth
=
gaugeWidth
/
5
;
const
thresholdMarkersWidth
=
gaugeWidth
/
5
;
const
thresholdLabelFontSize
=
fontSize
/
2.5
;
const
thresholdLabelFontSize
=
fontSize
/
2.5
;
const
formattedThresholds
=
thresholds
.
map
((
threshold
,
index
)
=>
{
const
formattedThresholds
=
[
return
{
{
value
:
minValue
,
color
:
BasicGaugeColor
.
Green
},
value
:
threshold
.
value
,
...
thresholds
.
map
((
threshold
,
index
)
=>
{
// Hacky way to get correct color for threshold.
return
{
color
:
index
===
0
?
threshold
.
color
:
thresholds
[
index
-
1
].
color
,
value
:
threshold
.
value
,
};
// Hacky way to get correct color for threshold.
});
color
:
index
===
0
?
threshold
.
color
:
thresholds
[
index
-
1
].
color
,
};
}),
{
value
:
maxValue
,
color
:
BasicGaugeColor
.
Red
,
},
];
console
.
log
(
formattedThresholds
);
console
.
log
(
formattedThresholds
);
...
@@ -174,11 +181,7 @@ export class Gauge extends PureComponent<Props> {
...
@@ -174,11 +181,7 @@ export class Gauge extends PureComponent<Props> {
value
:
{
value
:
{
color
:
this
.
getFontColor
(
value
),
color
:
this
.
getFontColor
(
value
),
formatter
:
()
=>
{
formatter
:
()
=>
{
if
(
timeSeries
[
0
])
{
return
this
.
formatValue
(
value
);
return
this
.
formatValue
(
value
);
}
return
''
;
},
},
font
:
{
font
:
{
size
:
fontSize
,
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