changeset 6932:9f19d1fa1474

statistics: hide checkboxes, instead click on user names directly This look much better. The now hidden checkboxes are still used to store the status. TODO: maybe we'll find a better cleaner way to do this in the future
author domruf <dominikruf@gmail.com>
date Tue, 22 Aug 2017 21:10:14 +0200
parents 6dd14c834acf
children 2c0e7e1d2584
files kallithea/templates/summary/statistics.html
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/templates/summary/statistics.html	Sun Aug 06 12:46:03 2017 +0200
+++ b/kallithea/templates/summary/statistics.html	Tue Aug 22 21:10:14 2017 +0200
@@ -158,7 +158,13 @@
 
     var plot_options = {
         bars: {show:true, align: 'center', lineWidth: 4},
-        legend: {show:true, container: "#legend_container"},
+        legend: {show:true,
+                container: "#legend_container",
+                labelFormatter: function(label, series) {
+                        // series is the series object for the label
+                        return '<a href="javascript:void(0)"> ' + label + '</a>';
+                    }
+        },
         points: {show:true, radius: 0, fill: false},
         yaxis: {tickDecimals: 0},
         xaxis: {
@@ -216,7 +222,7 @@
             i++;
             if(data[pos].label != ''){
                 choiceContainerTable.innerHTML +=
-                    '<tr><td><label><input type="checkbox" id="id_user_{0}" name="{0}" checked="checked" /> \
+                    '<tr style="display:none"><td><label><input type="checkbox" id="id_user_{0}" name="{0}" checked="checked" /> \
                      {0}</label></td></tr>'.format(data[pos].label);
             }
         }
@@ -292,6 +298,7 @@
 
         var new_data = [];
         var inputs = choiceContainer.getElementsByTagName("input");
+        inputs[$(e.target).parents('tr').index()].click();
 
         //show only checked labels
         for(var i=0; i<inputs.length; i++) {
@@ -329,6 +336,9 @@
        //resubscribe plothover
        $plotContainer.on("plothover", plothover);
 
+       //resubscribe this function after plot update
+       $('#legend_container tr a').on("click", [cur_data, cur_ranges], plotchoiced);
+
        // don't fire event on the overview to prevent eternal loop
        overview.setSelection(cur_ranges, true);
 
@@ -364,7 +374,7 @@
         overview.setSelection(ranges, true);
 
         //resubscribe choiced
-        $(choiceContainer.getElementsByTagName("input")).on("click", [data, ranges], plotchoiced);
+        $('#legend_container tr a').on("click", [data, ranges], plotchoiced);
     }
 
     var previousPoint = null;
@@ -444,7 +454,7 @@
     });
 
     // user choices on overview
-    $(choiceContainer.getElementsByTagName("input")).on("click", [data, initial_ranges], plotchoiced);
+    $('#legend_container tr a').on("click", [data, initial_ranges], plotchoiced);
 }
 
 SummaryPlot(${h.js(c.ts_min)}, ${h.js(c.ts_max)}, ${h.js(c.commit_data)}, ${h.js(c.overview_data)});