Fixes invalid chart units in community mode

Fixes #5448
This commit is contained in:
Simone Mainardi 2021-06-07 13:03:09 +02:00
parent 1ca6effc02
commit aa639c6123

View file

@ -526,6 +526,17 @@ function graph_utils.drawGraphs(ifid, schema, tags, zoomLevel, baseurl, selected
local label = data.series[1].label
-- Attempt at reading the formatter from the options using the schema
local formatter
if options and options.timeseries then
for _, cur_ts in pairs(options.timeseries or {}) do
if cur_ts.schema == schema and cur_ts.value_formatter then
formatter = cur_ts.value_formatter[1] or cur_ts.value_formatter
break
end
end
end
if label == "load_percentage" then
formatter_fctn = "NtopUtils.ffloat"
format_as_bps = false
@ -548,6 +559,11 @@ function graph_utils.drawGraphs(ifid, schema, tags, zoomLevel, baseurl, selected
formatter_fctn = "NtopUtils.fint"
format_as_bytes = false
format_as_bps = false
elseif formatter then
-- The formatter specified in the options
formatter_fctn = formatter
format_as_bytes = false
format_as_bps = false
else
formatter_fctn = (is_system_interface and "NtopUtils.fnone" or "NtopUtils.fbits")
end