Sha256: 69b9a064b45537ba13518db7a9f6739fadc7cac794a1c793973d462beef207e5

Contents?: true

Size: 641 Bytes

Versions: 2

Compression:

Stored size: 641 Bytes

Contents

class FnordMetric::TimelineWidget  < FnordMetric::Widget

  def data_labels
    ticks.map do |t|
      Time.at(t).strftime('%d.%m.%y %H:%M')
    end
  end

  def data_series
    gauges.map do |gauge|
      { 
        :color => next_series_colour,
        :data => ticks.map{ |t| gauge.value_at(t)||0 }
      }
    end
  end

  def next_series_colour
    @series_colors.pop.tap do |color|
      @series_colors.unshift(color)
    end
  end

  def data
    @series_colors = ["#FACE4F", "#42436B", "#CD645A", "#2F635E"]

    super.merge(
      :labels => data_labels,
      :series => data_series
    )
  end

  def has_tick?
    true
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fnordmetric-0.5.1 lib/fnordmetric/timeline_widget.rb
fnordmetric-0.5.0 lib/fnordmetric/timeline_widget.rb