Commit 2e7ec7d5 authored by Tadas Sce's avatar Tadas Sce
Browse files

Show percentage in tooltips for histograms

parent 72f3acdd
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
  %ul.ui_numbers(style="float:right;")
    %li
      .val
        %span.ui_value(data-value="#{@samples}")
        %span.ui_value.samples(data-value="#{@samples}")
      .title Number of Samples
    %li
      .val
+3 −1
Original line number Diff line number Diff line
@@ -2183,13 +2183,15 @@ Rickshaw.Graph.Renderer.Bar = Rickshaw.Class.create( Rickshaw.Graph.Renderer, {
      } );


      var total = $('.ui_numbers .samples').data('value');
      $('.widget_histogram_bars .tooltip').remove();
      $('.widget_histogram_bars rect').each(function(hist_i) {
        var percentage = Math.round(sdata[hist_i].y * 1000 / total) / 10;
        var left = parseInt($(this).offset().left);
        var top = parseInt($(this).offset().top) - 23;
        var tooltip = '<div class="tooltip" data-hist-id="' + hist_i
          + '" style="left:' + left + 'px; top: ' + top + 'px">'
          + sdata[hist_i].y + '</div>';
          + sdata[hist_i].y + ' (' + percentage + '%)' + '</div>';
        $(this).parents('.widget_histogram_bars:first').append(tooltip);
        $(this).attr('data-id', hist_i);
      });