% ' Get KB article counts by application/topic (top 8 + Others) strSQL_KB = "SELECT a.appname, COUNT(k.linkid) as article_count " & _ "FROM applications a " & _ "LEFT JOIN knowledgebase k ON a.appid = k.appid AND k.isactive = 1 " & _ "WHERE a.isactive = 1 " & _ "GROUP BY a.appid, a.appname " & _ "HAVING article_count > 0 " & _ "ORDER BY article_count DESC " & _ "LIMIT 8" Set rsKB = objconn.Execute(strSQL_KB) ' Get total count strSQL_Total = "SELECT COUNT(*) as total FROM knowledgebase WHERE isactive = 1" Set rsTotal = objconn.Execute(strSQL_Total) totalArticles = CLng(rsTotal("total")) rsTotal.Close Set rsTotal = Nothing ' Build arrays for chart data Dim appNames(), appCounts() ReDim appNames(7) ReDim appCounts(7) Dim i, topCount i = 0 topCount = 0 Do While Not rsKB.EOF And i < 8 appNames(i) = rsKB("appname") appCounts(i) = CLng(rsKB("article_count")) topCount = topCount + appCounts(i) i = i + 1 rsKB.MoveNext Loop rsKB.Close Set rsKB = Nothing ' Calculate "Others" category Dim actualCount actualCount = i Dim othersCount othersCount = totalArticles - topCount ' Build labels and data strings for JavaScript Dim labels, dataValues, colors labels = "" dataValues = "" colors = "" For i = 0 To actualCount - 1 If labels <> "" Then labels = labels & ", " dataValues = dataValues & ", " colors = colors & ", " End If labels = labels & """" & Replace(appNames(i), """", "\""") & """" dataValues = dataValues & appCounts(i) ' Generate color with opacity based on position Dim opacity If i = 0 Then colors = colors & """#ffffff""" Else opacity = FormatNumber(1 - (i * 0.1), 2) colors = colors & """rgba(255, 255, 255, " & opacity & ")""" End If Next ' Add "Others" if there are more categories If othersCount > 0 Then If labels <> "" Then labels = labels & ", " dataValues = dataValues & ", " colors = colors & ", " End If labels = labels & """Others""" dataValues = dataValues & othersCount colors = colors & """rgba(255, 255, 255, 0.20)""" End If %>
| <%=Server.HTMLEncode(appNames(rowIndex))%> | <%=rowCount%> | <%=rowPct%>% |
| Others | <%=othersCount%> | <%=othersPct%>% |