Merge pull request #501 from LuttyYang/master
[project/luci.git] / applications / luci-app-statistics / luasrc / statistics / rrdtool.lua
index 8d3482c..5d4ad98 100644 (file)
@@ -1,4 +1,4 @@
--- Copyright 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
+-- Copyright 2008 Freifunk Leipzig / Jo-Philipp Wich <jow@openwrt.org>
 -- Licensed to the public under the Apache License 2.0.
 
 module("luci.statistics.rrdtool", package.seeall)
@@ -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,
@@ -457,12 +458,24 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index )
                        _ti ( _args, "-X" )
                        _ti ( _args, opts.units_exponent )
                end
+               if opts.alt_autoscale then
+                       _ti ( _args, "-A" )
+               end
+               if opts.alt_autoscale_max then
+                       _ti ( _args, "-M" )
+               end
 
                -- store additional rrd options
                if opts.rrdopts then
                        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