diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2012-12-14 13:27:39 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2012-12-14 13:27:39 +0000 |
commit | 1461a0dba1dc17cbae0963be3149fd1e8fe99698 (patch) | |
tree | 9ef6df5382f4e50b6ce5568891c38751943ae782 /applications/luci-statistics | |
parent | 900515f0a6f63ae7b711de69e3a7c80735ca0259 (diff) |
luci-statistics: don't plot data points where there are no data.
Converting NaN to zero for the sake of the cumulative stack in non-overlay
mode is all very well. But we shouldn't then use that for displaying the
graph. Make another variable %s_plot which *preserves* NaN from the input
data, and then we don't get bogus data points drawn. Especially at the end
of the graph this was problematic.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'applications/luci-statistics')
-rw-r--r-- | applications/luci-statistics/luasrc/statistics/rrdtool.lua | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool.lua b/applications/luci-statistics/luasrc/statistics/rrdtool.lua index 844c157d1..45deb8509 100644 --- a/applications/luci-statistics/luasrc/statistics/rrdtool.lua +++ b/applications/luci-statistics/luasrc/statistics/rrdtool.lua @@ -180,20 +180,23 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index ) -- is first source in stack or overlay source: source_stk = source_nnl if not prev or source.overlay then - -- create cdef statement + -- create cdef statement for cumulative stack (no NaNs) and also + -- for display (preserving NaN where no points should be displayed) _tif( _args, "CDEF:%s_stk=%s_nnl", source.sname, source.sname ) + _tif( _args, "CDEF:%s_plot=%s_avg", source.sname, source.sname ) -- is subsequent source without overlay: source_stk = source_nnl + previous_stk else -- create cdef statement _tif( _args, "CDEF:%s_stk=%s_nnl,%s_stk,+", source.sname, source.sname, prev ) + _tif( _args, "CDEF:%s_plot=%s_avg,%s_stk,+", source.sname, source.sname, prev ) end -- create multiply by minus one cdef if flip is enabled if source.flip then -- create cdef statement: source_stk = source_stk * -1 - _tif( _args, "CDEF:%s_neg=%s_stk,-1,*", source.sname, source.sname ) + _tif( _args, "CDEF:%s_neg=%s_plot,-1,*", source.sname, source.sname ) -- push to negative stack if overlay is disabled if not source.overlay then @@ -253,11 +256,11 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index ) -- derive area background color from line color area_color = self.colors:to_string( self.colors:faded( area_color ) ) - -- choose source_stk or source_neg variable depending on flip state + -- choose source_plot or source_neg variable depending on flip state if source.flip then var = "neg" else - var = "stk" + var = "plot" end -- create legend |