summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua
diff options
context:
space:
mode:
authorHannu Nyman <hannu.nyman@iki.fi>2019-08-01 00:41:14 +0300
committerHannu Nyman <hannu.nyman@iki.fi>2019-08-01 01:04:40 +0300
commit4ca5727785ddeec33e26c6f8e5f5390ac2c75ed7 (patch)
tree5751043ef384e7f0006103c626f01ba879aae6bb /applications/luci-app-statistics/luasrc/statistics/rrdtool.lua
parente6f30bb7f39c67e1b2eaf312aa8d1f06e7b0a0ab (diff)
luci-app-statistics: add options for graph series sorting and color
Add two data series-level options "negweight" and "posweight" that will use the numerical value of the data instance name as the sorting factor. This enables e.g. sorting by CPU frequency in the cpufreq module. Add new graph-level option "ordercolor" to use colorsfrom a pre-defined color table for the data series. This enables keeping similar colors for similar data series in different plugin instances. E.g. CPU frequencies in several cores that are handled and displayed separately. (note: the table has 8 items and if there are more series, it uses the same colors again. The table can be easily extended/modified) Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
Diffstat (limited to 'applications/luci-app-statistics/luasrc/statistics/rrdtool.lua')
-rw-r--r--applications/luci-app-statistics/luasrc/statistics/rrdtool.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua
index 4586b23caa..c4ea88de92 100644
--- a/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua
+++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua
@@ -407,7 +407,9 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index )
transform_rpn = dopts.transform_rpn or "0,+",
noarea = dopts.noarea or false,
title = dopts.title or nil,
- weight = dopts.weight or nil,
+ weight = dopts.weight or
+ (dopts.negweight and -tonumber(dinst)) or
+ (dopts.posweight and tonumber(dinst)) or nil,
ds = dsource,
type = dtype,
instance = dinst,
@@ -487,6 +489,13 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index )
return x < y
end)
+ -- define colors in order
+ if opts.ordercolor then
+ for i, source in ipairs(_sources) do
+ source.color = self.colors:defined(i)
+ end
+ end
+
-- create DEF statements for each instance
for i, source in ipairs(_sources) do
-- fixup properties for per instance mode...