Module: Prosperity::GraphHelper
- Defined in:
- app/helpers/prosperity/graph_helper.rb
Instance Method Summary collapse
- #options_for_extractors ⇒ Object
- #options_for_metric(metrics) ⇒ Object
- #render_graph(graph, options = {}) ⇒ Object
Instance Method Details
#options_for_extractors ⇒ Object
3 4 5 |
# File 'app/helpers/prosperity/graph_helper.rb', line 3 def Prosperity::Metric.extractors.keys.map(&:to_s).sort end |
#options_for_metric(metrics) ⇒ Object
7 8 9 |
# File 'app/helpers/prosperity/graph_helper.rb', line 7 def (metrics) metrics.map{|m| [m.title, m.id]}.sort_by(&:first) end |
#render_graph(graph, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/prosperity/graph_helper.rb', line 11 def render_graph(graph, = {}) path_opts = .slice(:start_time, :end_time, :option, :period) path = case graph when Graph graph_path(graph, path_opts) when Metric metric_path(graph, path_opts) else raise "Unsupported object #{graph.class}" end classes = [Array([:class]) + ['metric']].flatten.uniq render partial: "prosperity/graphs/render_graph", locals: { graph: graph, classes: classes, path: path, } end |