lib/fnordmetric/timeline_widget.rb in fnordmetric-0.5.1 vs lib/fnordmetric/timeline_widget.rb in fnordmetric-0.5.2
- old
+ new
@@ -1,34 +1,27 @@
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
+ :gauges => gauges.map(&:name),
+ :gauge_titles => gauge_titles,
+ :start_timestamp => ticks.first,
+ :end_timestamp => ticks.last,
+ :autoupdate => (@opts[:autoupdate] || 60),
+ :include_current => !!@opts[:include_current],
+ :plot_style => (@opts[:plot_style] || 'line'),
+ :tick => tick
)
+ end
+
+ def gauge_titles
+ {}.tap do |_hash|
+ gauges.each do |gauge|
+ _hash.merge!(gauge.name => gauge.title)
+ end
+ end
end
def has_tick?
true
end
\ No newline at end of file