tilde.news/lib/time_series.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
572 B
Ruby
Raw Normal View History

2023-09-14 13:37:09 +00:00
# typed: false
2020-07-03 23:29:24 +00:00
class TimeSeries < SVG::Graph::TimeSeries
include ActionView::Helpers::NumberHelper
# these two methods are a patch on the gem's lack of time zone awareness
def format x, y, description
[
Time.at(x).utc.strftime(popup_format),
number_with_delimiter(y),
description
].compact.join(", ")
end
def get_x_labels
get_x_values.collect { |v| Time.at(v).utc.strftime(x_label_format) }
end
# improves y axis labels with commas
def get_y_labels
get_y_values.collect { |v| number_with_delimiter(v.to_i) }
end
end