added sort_key to data_to_lines and sort versions numerically
authorForrest Voight <forrest@forre.st>
Sun, 6 May 2012 13:56:17 +0000 (09:56 -0400)
committerForrest Voight <forrest@forre.st>
Mon, 7 May 2012 23:23:36 +0000 (19:23 -0400)
web-static/graphs.html

index 64f7c8e..72d330c 100644 (file)
                 });
             }
             
-            function data_to_lines(data) {
+            function data_to_lines(data, sort_key) {
                 var vers = {}; for(var i = 0; i < data.length; ++i) for(var v in data[i][1]) vers[v] = null;
                 var verlist = []; for(var v in vers) verlist.push(v);
                 verlist.sort();
                         label: verlist[i]
                     });
                 }
-                function m(x) { return d3.max(x.data, function(d){ return d[1] }) }
-                lines.sort(function(a, b){ return m(a) - m(b) });
+                if(sort_key == undefined)
+                    var sort_key = function(x) { return d3.max(x.data, function(d){ return d[1] }) }
+                lines.sort(function(a, b){ return sort_key(a) - sort_key(b) });
                 return lines;
             }
             
                 });
                 
                 d3.json("/web/graph_data/desired_versions/last_" + lowerperiod, function(data) {
-                    plot(d3.select('#desired_versions'), '', null, data_to_lines(data));
+                    plot(d3.select('#desired_versions'), '', null, data_to_lines(data, function(line){ return parseInt(line.label) }), true);
                 });
             }