Add command and invocation counts to header

This commit is contained in:
Kevin Sawicki
2013-01-04 16:36:14 -08:00
parent 65d13b5383
commit f78adfa060
3 changed files with 27 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ class CommandLogger extends ScrollView
@content: (rootView) ->
@div class: 'command-logger', tabindex: -1, =>
@h1 class: 'category-header', outlet: 'categoryHeader'
@h1 class: 'category-summary', outlet: 'categorySummary'
@div class: 'tree-map', outlet: 'treeMap'
@serialize: ->
@@ -95,12 +96,22 @@ class CommandLogger extends ScrollView
y = d3.scale.linear().range([0, h])
color = d3.scale.category20()
setCategoryHeader = (node) =>
updateCategoryHeader = (node) =>
@categoryHeader.text("#{node.name} Commands")
setCategoryHeader(root)
reduceChildren = (previous, current) ->
if current.size?
previous + current.size
else if current.children?.length > 0
previous + current.children.reduce(reduceChildren, 0)
else
previous
commandCount = node.children.length
runCount = node.children.reduce(reduceChildren, 0)
@categorySummary.text("#{_.pluralize(commandCount, 'command')}, #{_.pluralize(runCount, 'invocation')}")
updateCategoryHeader(root)
zoom = (d) ->
setCategoryHeader(d)
updateCategoryHeader(d)
kx = w / d.dx
ky = h / d.dy
x.domain([d.x, d.x + d.dx])

View File

@@ -12,8 +12,15 @@
}
.command-logger .category-header {
text-align: center;
padding-bottom: 5px;
font-size: 16px;
}
.command-logger .category-summary {
text-align: center;
padding-bottom: 10px;
font-size: 12px;
}
.command-logger .tree-map {

View File

@@ -63,6 +63,12 @@ _.mixin
capitalize: (word) ->
word[0].toUpperCase() + word[1..]
pluralize: (count=0, singular, plural=singular+'s') ->
if count is 1
"#{count} #{singular}"
else
"#{count} #{plural}"
losslessInvert: (hash) ->
inverted = {}
for key, value of hash