Commits

Simon Cross committed e92b24d

Allow specifying initial plot in URL hash.

Comments (0)

Files changed (2)

 
 (function(exports) {
 
+    function plot_for_hash() {
+        return window.location.hash.substring(1);
+    }
+
     function attach(opts) {
 
         opts.chart_selector.empty();
         var $select = $($.parseHTML("<select></select>"));
         opts.chart_selector.append($select);
 
+        var initial = opts.initial || plot_for_hash();
+        initial = distri.plots.all[initial] ? initial : "binomial";
+
         function select_plot() {
-            console.log($select.val())
             $(opts.chart).empty();
             var svg = dimple.newSvg(opts.chart, 800, 400);
             var chart = new dimple.chart(svg, []);
         });
 
         $select.change(select_plot);
-        $select.val(opts.initial);
+        $select.val(initial);
         select_plot();
     }
 
             chart_selector: $("#chart_selector"),
             chart_title: $("#chart_title"),
             chart_footer: $("#chart_footer"),
-            initial: "binomial"
         });
     });
   </script>