Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

add color scheme to stat and gauge panel #316

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion grafonnet/gauge_panel.libsonnet
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
* @param repeat (optional) Name of variable that should be used to repeat this panel.
* @param repeatDirection (default `'h'`) 'h' for horizontal or 'v' for vertical.
* @param repeatMaxPerRow (optional) Maximum panels per row in repeat mode.
* @param timeFrom (optional)
* @param pluginVersion (default `'7'`) Plugin version the panel should be modeled for. This has been tested with the default, '7', and '6.7'.
*
* @method addTarget(target) Adds a target object.
@@ -36,7 +37,7 @@
* @method addMappings(mappings) Adds an array of value mappings.
* @method addDataLink(link) Adds a data link.
* @method addDataLinks(links) Adds an array of data links.
* @param timeFrom (optional)
* @method addColorScheme(fixedColor, mode) Add a color scheme option. https://grafana.com/docs/grafana/latest/panels/field-options/standard-field-options/#color-scheme
*/
new(
title,
@@ -156,6 +157,21 @@
},
},
addOverrides(overrides):: std.foldl(function(p, o) p.addOverride(o.matcher, o.properties), overrides, self),

// Color Scheme
addColorScheme(
fixedColor=null,
mode=null,
):: self {
fieldConfig+: {
defaults+: {
color: {
[if fixedColor != null then 'fixedColor']: fixedColor,
[if mode != null then 'mode']: mode,
},
},
},
},
} else {

options: {
16 changes: 16 additions & 0 deletions grafonnet/stat_panel.libsonnet
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
* @method addMappings(mappings) Adds an array of value mappings.
* @method addDataLink(link) Adds a data link.
* @method addDataLinks(links) Adds an array of data links.
* @method addColorScheme(fixedColor, mode) Add a color scheme option. https://grafana.com/docs/grafana/latest/panels/field-options/standard-field-options/#color-scheme
*/
new(
title,
@@ -162,6 +163,21 @@
},
},
addOverrides(overrides):: std.foldl(function(p, o) p.addOverride(o.matcher, o.properties), overrides, self),

// Color Scheme
addColorScheme(
fixedColor=null,
mode=null,
):: self {
fieldConfig+: {
defaults+: {
color: {
[if fixedColor != null then 'fixedColor']: fixedColor,
[if mode != null then 'mode']: mode,
},
},
},
},
} else {
options: {
fieldOptions: {