Skip to content

Instantly share code, notes, and snippets.

@kastner
Created September 15, 2010 14:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kastner/580783 to your computer and use it in GitHub Desktop.
Save kastner/580783 to your computer and use it in GitHub Desktop.
diff -ru a/webapp/content/js/composer_widgets.js b/webapp/content/js/composer_widgets.js
--- a/webapp/content/js/composer_widgets.js 2010-02-26 16:12:54.000000000 +0000
+++ b/webapp/content/js/composer_widgets.js 2010-09-15 07:03:56.000000000 +0000
@@ -531,6 +531,7 @@
{text: 'Line Width', handler: this.applyFuncToEachWithInput('lineWidth', 'Please enter a line width for this graph target')},
{text: 'Dashed Line', handler: this.applyFuncToEach('dashed')},
{text: 'Keep Last Value', handler: this.applyFuncToEach('keepLastValue')},
+ {text: 'Fill Value', handler: this.applyFuncToEachWithInput('fillValue', 'Please enter a value to fill. Leave blank for 0', true)},
{text: 'Substring', handler: this.applyFuncToEachWithInput('substr', 'Enter a starting position')}
]
}
diff -ru a/webapp/graphite/render/functions.py b/webapp/graphite/render/functions.py--- a/webapp/graphite/render/functions.py 2010-01-25 05:21:31.000000000 +0000
+++ b/webapp/graphite/render/functions.py 2010-09-15 06:58:27.000000000 +0000
@@ -141,6 +141,15 @@
series[i] = value
return seriesList
+def fillValue(seriesList, placeholder=0):
+ for series in seriesList:
+ series.name = "fillValue(%s, %i)" % (series.name, placeholder)
+ for i,value in enumerate(series):
+ if value is None and i != 0:
+ value = placeholder
+ series[i] = value
+ return seriesList
+
def asPercent(seriesList1,seriesList2orNumber):
assert len(seriesList1) == 1, "asPercent series arguments must reference *exactly* 1 series"
series1 = seriesList1[0]
@@ -490,6 +499,7 @@
'alias' : alias,
'cumulative' : cumulative,
'keepLastValue' : keepLastValue,
+ 'fillValue' : fillValue,
'drawAsInfinite' : drawAsInfinite,
'lineWidth' : lineWidth,
'dashed' : dashed,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment