From 9f321b831f41b73554819ac54e308dfa3677ab45 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Fri, 16 Dec 2022 23:22:04 +0100 Subject: luci-app-statistics: Generate graphs for humidity sensors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes graph generation for sensors that provide humidity data. Suggested-by: Jo-Philipp Wich Signed-off-by: Uwe Kleine-König --- .../statistics/rrdtool/definitions/sensors.js | 50 ++++++++++++++++------ 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions') diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sensors.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sensors.js index b3361e1bf4..3da1bcfd82 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sensors.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sensors.js @@ -7,20 +7,44 @@ return baseclass.extend({ title: _('Sensors'), rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - return { - per_instance: true, - title: "%H: %pi - %di", - vlabel: "\xb0C", - number_format: "%4.1lf\xb0C", - data: { - types: [ "temperature" ], - options: { - temperature__value: { - color: "ff0000", - title: "Temperature" + var rv = []; + var types = graph.dataTypes(host, plugin, plugin_instance); + + if (types.indexOf('temperature') > -1) { + rv.push({ + per_instance: true, + title: "%H: %pi - %di", + vlabel: "\xb0C", + number_format: "%4.1lf\xb0C", + data: { + types: [ "temperature" ], + options: { + temperature__value: { + color: "ff0000", + title: "Temperature" + } + } + } + }); + } + if (types.indexOf('humidity') > -1) { + rv.push({ + per_instance: true, + title: "%H: %pi - %di", + vlabel: "%RH", + number_format: "%4.1lf %%RH", + data: { + types: [ "humidity" ], + options: { + humidity__value: { + color: "0000ff", + title: "Humidity" + } } } - } - }; + }); + } + + return rv; } }); -- cgit v1.2.3