Fixes too many charts (#7610)

This commit is contained in:
Matteo Biscosi 2023-06-30 09:53:36 +00:00
parent 7efe9fb4dd
commit badd631ef7

View file

@ -17,6 +17,8 @@ local ifid = _GET["ifid"] or interface.getId()
interface.select(tostring(ifid))
local inactive_hosts_manufacturer = inactive_hosts_utils.getManufacturerFilters(ifid)--, inactive_hosts_utils.getFilters())
local max = 10
local other_num = 0
local series = {}
local labels = {}
local colors = {}
@ -32,14 +34,23 @@ local rsp = {
}
}
for _, info in pairs(inactive_hosts_manufacturer) do
if info.count then
for _, info in pairsByField(inactive_hosts_manufacturer, "count", rev) do
if info.count and max > 0 then
series[#series + 1] = info.count
labels[#labels + 1] = info.label
colors[#colors + 1] = graph_utils.get_html_color(#colors + 1)
colors[#colors + 1] = graph_utils.get_html_color(#colors + 1)
max = max - 1
elseif info.count then
other_num = other_num + info.count
end
end
if other_num > 0 then
series[#series + 1] = other_num
labels[#labels + 1] = i18n('others')
colors[#colors + 1] = graph_utils.get_html_color(#colors + 1)
end
rsp.series = series
rsp.labels = labels
rsp.colors = colors