Module: GoogleChartHelper
- Defined in:
- app/helpers/google_chart_helper.rb
Instance Method Summary collapse
- #chart_date_format(datetime, time = false) ⇒ Object
- #google_chart(type, headers, data, opts = {}, chart_id = "chart-#{SecureRandom.hex(10)}", parent_tag = :div) ⇒ Object
Instance Method Details
#chart_date_format(datetime, time = false) ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/helpers/google_chart_helper.rb', line 10 def chart_date_format(datetime, time=false) if time datetime.strftime "Date(%Y, %m, %d, %H, %M, %S)" else datetime.strftime "Date(%Y, %m, %d)" end end |
#google_chart(type, headers, data, opts = {}, chart_id = "chart-#{SecureRandom.hex(10)}", parent_tag = :div) ⇒ Object
3 4 5 6 7 8 |
# File 'app/helpers/google_chart_helper.rb', line 3 def google_chart type, headers, data, opts={}, chart_id="chart-#{SecureRandom.hex(10)}", parent_tag=:div content_tag(parent_tag) do c = content_tag(:script, {data: data.prepend(headers), options: opts}.to_json, {type: "text/json", chart: chart_id}, false) c << content_tag(:div, "", class: "google-chart", id: chart_id, chart_type: type) end end |