[162] Rearranging ga_reports graphs per ticket feedback. Series are sensibly ordered. Page is restructured.
[ckanext-ga-report.git] / ckanext / ga_report / public / scripts / ckanext_ga_reports.js
blob:a/ckanext/ga_report/public/scripts/ckanext_ga_reports.js -> blob:b/ckanext/ga_report/public/scripts/ckanext_ga_reports.js
--- a/ckanext/ga_report/public/scripts/ckanext_ga_reports.js
+++ b/ckanext/ga_report/public/scripts/ckanext_ga_reports.js
@@ -19,6 +19,8 @@
     $.each(data, function(i, object) {
         object['color'] = palette.color();
     });
+    // Rickshaw renders the legend in reverse order...
+    data.reverse();
 
     var graphElement =  document.querySelector("#chart_"+css_name);
 
@@ -97,6 +99,18 @@
   );
 };
 
+CKAN.GA_Reports.bind_month_selector = function() {
+  var handler = function(e) { 
+    var target = $(e.delegateTarget);
+    var form = target.closest('form');
+    form.attr('action', form.attr('action')+window.location.hash);
+    form.submit();
+  };
+  var selectors = $('select[name="month"]');
+  assert(selectors.length>0);
+  selectors.bind('change', handler);
+};
+
 /* 
  * Custom bootstrap plugin for handling data-toggle="hashchange".
  * Behaves like data-toggle="tab" but I respond to the hashchange.