Commit 5bab022f authored by Paul Asmuth's avatar Paul Asmuth
Browse files

realtime gauge drawing properly

parent 8404f5df
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -10,9 +10,17 @@ class FnordMetric::RealtimeGauge < FnordMetric::MultiGauge
    )
  end

  def initialized
    super

    timer1 = EventMachine::PeriodicTimer.new(0.01) do
      respond(:_class => "widget_push", :cmd => "value", :value => running_since)
    end
  end

  def react(event)
    if event["_class"] == "observe"
      respond(:_class => "widget_push", :cmd => "value", :value => rand(23))
      
    end
  end

+7 −1
Original line number Diff line number Diff line
@@ -38,7 +38,13 @@ FnordMetric.widgets.realtimeValueWidget = function(){

    function nextValue(value){
      if (value > max){
        var old_max = max;
        max = value * 1.2;
        canvas.selectAll('.valuebar').each(function(){
          var theight = parseInt($(this).attr('height'))*(old_max/max);
          $(this).attr("y", height-(ypadding*2)-theight)
          $(this).attr("height", theight);
        });
      }

      drawValue(value);
@@ -59,7 +65,7 @@ FnordMetric.widgets.realtimeValueWidget = function(){
          next_value_interval = window.setInterval(function(){
            var _v = next_values.pop();
            if(!!_v){ nextValue(_v); }
          }, 60);  
          }, 20);  
        }
      }   
    }