summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-statistics/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-10-05 19:11:13 +0200
committerJo-Philipp Wich <jow@openwrt.org>2015-10-05 19:11:13 +0200
commitc8c4a343c2e7ab2f7af00531d0c2fd30c33e51b4 (patch)
treead9b4c2e35d2e8d2a64c76230abbe5fd48951c20 /applications/luci-app-statistics/luasrc
parent3289e134953887482bdaa28c28567917bb91facb (diff)
luci-app-statistics: add support for sorting RRD data sources
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'applications/luci-app-statistics/luasrc')
-rw-r--r--applications/luci-app-statistics/luasrc/statistics/rrdtool.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua
index d8317a817..5d4ad9859 100644
--- a/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua
+++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua
@@ -397,6 +397,7 @@ 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,
ds = dsource,
type = dtype,
instance = dinst,
@@ -469,6 +470,12 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index )
for i, o in ipairs(opts.rrdopts) do _ti( _args, o ) end
end
+ -- sort sources
+ table.sort(_sources, function(a, b)
+ local x = a.weight or a.index or 0
+ local y = b.weight or b.index or 0
+ return x < y
+ end)
-- create DEF statements for each instance
for i, source in ipairs(_sources) do