Commit dc9bbc89 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

numbers widget: count down

parent 8b601456
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ class FnordMetric::NumericGauge < FnordMetric::MultiGauge
      :ticks => @opts[:ticks],
      :series => @opts[:series],
      :series_titles => Hash[@opts[:series].map{|s| [s, s]}],
      :autoupdate => 1,
      :autoupdate => 10,
      :height => 350
    ).on(:values_at) do |_series, _ticks, _tick|
      series_count_metrics[_series][_tick].values_at(_ticks)
@@ -23,7 +23,7 @@ class FnordMetric::NumericGauge < FnordMetric::MultiGauge
      :title => "Total #{key_nouns.last}",
      :series => @opts[:series],
      :series_titles => Hash[@opts[:series].map{|s| [s, s]}],
      :autoupdate => 1
      :autoupdate => 2
    ).on(:values_for) do |_series|
      render_series_numbers(_series.to_sym)
    end
+6 −3
Original line number Diff line number Diff line
@@ -106,12 +106,15 @@ FnordMetric.widgets._numbersWidget = function(){
      var target_val = parseFloat($(this).attr('data'));
      var current_val = parseFloat($(this).attr('data-current'));
      if(!current_val){ current_val=0; }
      if(!target_val){ target_val=0; }
      var diff = (target_val-current_val)/diff_factor;
      if(diff < 1){ diff=1; }
      if(target_val > current_val){
      if((diff > 0) && (diff < 1)){ diff=1; }
      if((diff < 0) && (diff > -1)){ diff=-1; }
      if(target_val != current_val){
        still_running = true;
        var new_val = current_val+diff;
        if(new_val > target_val){ new_val = target_val; }
        if((diff > 0) && (new_val > target_val)){ new_val = target_val; }
        if((diff < 0) && (new_val < target_val)){ new_val = target_val; }
        $(this).attr('data-current', new_val);
        $('.value', this).html(FnordMetric.util.formatGaugeValue($(this).attr('rel'), new_val));
      }