diff --git a/httpdocs/css/pie-chart.css b/httpdocs/css/pie-chart.css index e0b4d6f0c7..e096807183 100644 --- a/httpdocs/css/pie-chart.css +++ b/httpdocs/css/pie-chart.css @@ -23,8 +23,17 @@ } .pie-chart-small { - height: 260px; - width: 280px; + width:100%; + display: -webkit-flex; /* Safari */ + display: flex; + -webkit-align-items: center; /* Safari 7.0+ */ + align-items: center; + -webkit-justify-content: center; + justify-content: center; +} + +.pie-chart-small svg g.label_group text { + font-size: 0.95em; } .pie-chart .total{ diff --git a/httpdocs/js/pie-chart.js b/httpdocs/js/pie-chart.js index f46356759b..c6e17a3a37 100644 --- a/httpdocs/js/pie-chart.js +++ b/httpdocs/js/pie-chart.js @@ -328,9 +328,9 @@ function create_pie_chart(name, units) { var r = 116; //100; if($(name).hasClass("pie-chart-small")) { - w = 270; + w = 380; h = 250; - r = w / 3 - 20; + r = w / 5; ir = r / 2; } diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua index 397dd61004..7aa3a6df24 100644 --- a/scripts/locales/en.lua +++ b/scripts/locales/en.lua @@ -59,6 +59,7 @@ local en = { vlan = "VLAN", breakdown = "Breakdown", interface = "Interface", + other = "Other", graphs = { arp_requests = "ARP Requests", diff --git a/scripts/lua/modules/lua_utils.lua b/scripts/lua/modules/lua_utils.lua index 4050d4be93..4bd2307c9f 100644 --- a/scripts/lua/modules/lua_utils.lua +++ b/scripts/lua/modules/lua_utils.lua @@ -1165,6 +1165,45 @@ function aggregation2String(value) end end +-- ################################# + +-- Aggregates items below some edge +-- edge: minimum percentage value to create collision +-- min_col: minimum collision groups to aggregate +function aggregatePie(values, values_sum, edge, min_col) + local edge = edge or 0.05 + min_col = min_col or 2 + local aggr = {} + local other = i18n("other") + local below_edge = {} + + -- Initial lookup + for k,v in pairs(values) do + if v / values_sum <= edge then + -- too small + below_edge[#below_edge + 1] = k + else + aggr[k] = v + end + end + + -- Decide if to aggregate + for _,k in pairs(below_edge) do + if #below_edge >= min_col then + -- aggregate + aggr[other] = aggr[other] or 0 + aggr[other] = aggr[other] + values[k] + else + -- do not aggregate + aggr[k] = values[k] + end + end + + return aggr +end + +-- ################################# + function getOSIcon(name) icon = ""