changeset 12:279bee726817

dir sizes are now shown relative to the # of changesets that involve them, rather than their size in bytes.
author Atul Varma <varmaa@toolness.com>
date Sun, 13 Dec 2009 04:43:38 -0800
parents dc89fb1726b4
children d6d558244c61
files moztree.js
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/moztree.js	Sun Dec 13 00:42:21 2009 -0800
+++ b/moztree.js	Sun Dec 13 04:43:38 2009 -0800
@@ -27,10 +27,27 @@
   if (depth == 0 || !dir.subdirs)
     return;
 
+  dir.subdirs.sort(
+    function(a, b) {
+      return b[options.key] - a[options.key];
+    });
+
+  var total = 0;
+  dir.subdirs.forEach(
+    function(subdir) {
+      total += subdir[options.key];
+    });
+
+  if (total < dir[options.key])
+    total = dir[options.key];
+
+  if (total == 0)
+    return;
+
   var currY = options.y + options.height;
   dir.subdirs.forEach(
     function(subdir) {
-      var heightScale = subdir.size / dir.size;
+      var heightScale = subdir[options.key] / total;
       var height = options.height * heightScale;
       var y = currY - height;
 
@@ -56,6 +73,7 @@
 
       drawDir(svg, subdir, depth - 1, {x: options.x + options.width,
                                        y: y,
+                                       key: options.key,
                                        width: options.width,
                                        height: height,
                                        minHeight: options.minHeight,
@@ -85,6 +103,7 @@
   drawDir(group, tree, options.dirDepth,
           {x: 0,
            y: 0,
+           key: options.key,
            width: options.dirWidth,
            height: options.height,
            textPadding: options.textPadding,
@@ -121,6 +140,7 @@
 
     var svg = makeTree(dir,
                        {height: 2800,
+                        key: 'changes',
                         dirWidth: 120,
                         dirDepth: 6,
                         landscape: false,