luci-app-statistics: use stable random seed for dynamic graph colors
authorJo-Philipp Wich <jo@mein.io>
Fri, 21 Feb 2020 22:01:22 +0000 (23:01 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 21 Feb 2020 22:01:22 +0000 (23:01 +0100)
Fixes: #3666
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool.js

index 7949886f4ee34bea55fbb79f777d2f7539742aa4..fbb5da626d58a5d2e0e6822f66db21720f3db490 100644 (file)
@@ -335,6 +335,10 @@ return L.Class.extend({
                    _longest_name = 0,
                    _has_totals = false;
 
+               /* use the plugin+instance+type as seed for the prng to ensure the
+                  same pseudo-random color sequence for each render */
+               random.seed(sfh([plugin, plugin_instance || '', dtype || ''].join('.')));
+
                function __def(source) {
                        var inst = source.sname,
                            rrd  = source.rrd.replace(/[\\:]/g, '\\$&'),