Hey,
I'm trying to summarize all the of the status information given by the status macro in one graph. To do this I need the total count of each possible status. Is there any way to do this because i didnt find any macro that would be able to this and counting it manually would take too much time in the long run.
Many thanks in advance!
Hi,
Dou you want to count statuses in a single page? How do you place them (maybe in a table or Page Properties Report macro)?
i want to count the statuses of several pages. On the "main" page above I'm using the Page Properties Report Macro (+ labels) right now but I want to change it to a table, so that i can write the status name in one column and the count into another one.
My goal is to use the chart macro to display the information in a graph.
If you want to simply count all statuses in a single page (no filtering required), then you could simply install this simple user macro that puts a count of all same statuses (i.e. if the text is different, then it counts as unique) on a page in a table:
## @noparams<table> <tbody id="status-table"> <tr> <th>Status</th> <th>Count</th> </tr> </tbody></table><script>AJS.toInit(function() { var statusTable = jQuery("#status-table"); var statusMacros = {}; jQuery(".status-macro").each(function() { if (statusMacros.hasOwnProperty(this.outerHTML)) { statusMacros[this.outerHTML] += 1; } else { statusMacros[this.outerHTML] = 1; } }); Object.keys(statusMacros).forEach(function(key) { statusTable.append('<tr><td class="confluenceTd">' + key + '</td><td class="confluenceTd"><p>' + statusMacros[key] + '</p></td></tr>') });});</script>
Ah, I think this is what you're looking for, but it renders the table on the front-end, so it wouldn't be able to be inserted into the graph macro... let me see if I can figure out how to do it on the back-end.
Then you can use Pivot Table macro to count each status in a table or PPR macro. And you can use Chart from Table macro to visualize it.
Both macro are shipped with Table Filter and Charts add-on.
Here is the video with your case.
In case someone wants to try it without installing a plugin, here's a user macro that should work inside the chart macro (but it won't be displayed properly until you save the page):
## @noparams#set ( $container = {} )#set( $contentBody = $content.bodyAsString )#foreach ( $part in $contentBody.split('(?=<ac:structured-macro)|(?<=\/ac:structured-macro>)') ) #if ( $part.contains('ac:name="status"') ) #set ( $status = $part.replaceAll(' ac:macro-id=".{36}"', '') ) #set ( $statusCount = false ) #set ( $statusCount = $container.get($status) ) #if ( $statusCount ) #set ( $statusCount = $statusCount + 1 ) #set ( $void = $container.put($status, $statusCount) ) #else #set ( $void = $container.put($status, 1) ) #end #end#end<table> <tbody> <tr> <th>Status</th> <th>Count</th> </tr> #foreach ( $status in $container.keySet() ) <tr> <td>$status</td> <td>$container.get($status)</td> </tr> #end </tbody></table>
that looks great, I'm trying to include this into my page right now.
I'm just a bit lost on where exactly to include the code block?
My diagram area looks somewhat like this (simplified):
How can I should do if I want to count statuses from more page? @Stephen Deutsch
It looks like you're new here. Sign in or register to get started.