[321] Redraw sparklines on tab refresh
[321] Redraw sparklines on tab refresh

--- a/ckanext/ga_report/public/css/ga_report.css
+++ b/ckanext/ga_report/public/css/ga_report.css
@@ -18,6 +18,7 @@
 .rickshaw_legend {
   background: transparent;
   width: 100%;
+  padding-top: 4px;
 }
 .rickshaw_y_axis {
   position: absolute;
@@ -29,6 +30,10 @@
   background: transparent !important;
   color: #000000 !important;
   font-weight: normal !important;
+}
+.rickshaw_legend .instructions {
+  color: #000;
+  margin-bottom: 6px;
 }
 
 .rickshaw_legend .line .action {
@@ -44,6 +49,9 @@
   float: left;
   width: 200px;
 }
+.rickshaw_legend .line .label:hover {
+  text-decoration: underline;
+}
 
 .ga-reports-table .td-numeric {
   text-align: center;

--- a/ckanext/ga_report/public/scripts/ckanext_ga_reports.js
+++ b/ckanext/ga_report/public/scripts/ckanext_ga_reports.js
@@ -45,6 +45,7 @@
       graph: graph,
       legend: legend
     } );
+    myLegend.prepend('<div class="instructions">Click on a series below to isolate its graph:</div>');
     graph.render();
 };
 
@@ -54,24 +55,29 @@
    * Sparkline graphs should be drawn.
    * Note that they cannot be drawn sooner.
    */
+  var created = false;
   $('a[href="#totals"]').on(
     'shown', 
-    function() {
-      var sparkOptions = {
-        enableTagOptions: true,
-        type: 'line',
-        width: 100,
-        height: 26,
-        chartRangeMin: 0,
-        spotColor: '',
-        maxSpotColor: '',
-        minSpotColor: '',
-        highlightSpotColor: '000000',
-        lineColor: '3F8E6D',
-        fillColor: 'B7E66B'
-      };
-      $('.sparkline').sparkline('html',sparkOptions);
-    }
+      function() {
+        if (!created) {
+          var sparkOptions = {
+            enableTagOptions: true,
+            type: 'line',
+            width: 100,
+            height: 26,
+            chartRangeMin: 0,
+            spotColor: '',
+            maxSpotColor: '',
+            minSpotColor: '',
+            highlightSpotColor: '000000',
+            lineColor: '3F8E6D',
+            fillColor: 'B7E66B'
+          };
+          $('.sparkline').sparkline('html',sparkOptions);
+          created = true;
+        }
+        $.sparkline_display_visible();
+      }
   );
 };
 
@@ -94,6 +100,7 @@
       }
       legend_name = '#legend_'+legend_name;
       $('#graph-legend-container > *').hide();
+      $('#graph-legend-container .instructions').show();
       $(legend_name).show();
     }
   );

--- a/ckanext/ga_report/templates/ga_report/publisher/index.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/index.html
@@ -24,8 +24,8 @@
 
   <py:def function="optional_head">
     <link rel="stylesheet" type="text/css" href="/scripts/vendor/rickshaw.min.css"/>
-    <link rel="stylesheet" type="text/css" href="/css/ga_report.css"/>
-    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js"></script>
+    <link rel="stylesheet" type="text/css" href="/css/ga_report.css?1"/>
+    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js?1"></script>
     <script type="text/javascript" src="/scripts/vendor/jquery.sparkline.modified.js"></script>
     <script type="text/javascript" src="/scripts/rickshaw_ie7_shim.js"></script>
     <script type="text/javascript" src="/scripts/vendor/d3.v2.js"></script>

--- a/ckanext/ga_report/templates/ga_report/publisher/read.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/read.html
@@ -9,8 +9,8 @@
 
   <py:def function="optional_head">
     <link rel="stylesheet" type="text/css" href="/scripts/vendor/rickshaw.min.css"/>
-    <link rel="stylesheet" type="text/css" href="/css/ga_report.css"/>
-    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js"></script>
+    <link rel="stylesheet" type="text/css" href="/css/ga_report.css?1"/>
+    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js?1"></script>
     <script type="text/javascript" src="/scripts/vendor/jquery.sparkline.modified.js"></script>
     <script type="text/javascript" src="/scripts/rickshaw_ie7_shim.js"></script>
     <script type="text/javascript" src="/scripts/vendor/d3.v2.js"></script>

--- a/ckanext/ga_report/templates/ga_report/site/index.html
+++ b/ckanext/ga_report/templates/ga_report/site/index.html
@@ -9,8 +9,8 @@
 
   <py:def function="optional_head">
     <link rel="stylesheet" type="text/css" href="/scripts/vendor/rickshaw.min.css"/>
-    <link rel="stylesheet" type="text/css" href="/css/ga_report.css"/>
-    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js"></script>
+    <link rel="stylesheet" type="text/css" href="/css/ga_report.css?1"/>
+    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js?1"></script>
     <script type="text/javascript" src="/scripts/vendor/jquery.sparkline.modified.js"></script>
     <script type="text/javascript" src="/scripts/rickshaw_ie7_shim.js"></script>
     <script type="text/javascript" src="/scripts/vendor/d3.v2.js"></script>