changed graph switching to use links instead of event handlers. individual views...
authorForrest Voight <forrest@forre.st>
Thu, 18 Oct 2012 04:58:53 +0000 (00:58 -0400)
committerForrest Voight <forrest@forre.st>
Thu, 18 Oct 2012 04:58:53 +0000 (00:58 -0400)
web-static/graphs.html

index ad4f1ca..fc30140 100644 (file)
                 });
             }
             
+            periods = ["Hour", "Day", "Week", "Month", "Year"];
+            d3.select("#period_chooser").selectAll().data(periods).enter().append("a")
+                .text(function(period) { return period })
+                .attr('href', function(period){ return "?" + period })
+                .attr("style", function(d, i) { return (i == 0 ? "" : "margin-left:.4em;") + "color:blue;text-decoration:underline;cursor:pointer" });
+            period = window.location.search.substr(1);
+            if(period == "") {
+                window.location.search = "Day";
+            }
             d3.json('/web/currency_info', function(currency_info) {
-                periods = ["Hour", "Day", "Week", "Month", "Year"];
-                d3.select("#period_chooser").selectAll().data(periods).enter().append("span")
-                    .text(function(period) { return period })
-                    .on("click", function(period){ change_period(period, currency_info) })
-                    .attr("style", function(d, i) { return (i == 0 ? "" : "margin-left:.4em;") + "color:blue;text-decoration:underline;cursor:pointer" });
-                change_period(periods[1], currency_info);
+                change_period(period, currency_info);
             });
         </script>
     </body>