Module: Kadmin::ChartsHelper
- Defined in:
- app/helpers/kadmin/charts_helper.rb
Overview
Provide helpers for displaying charts based on www.chartjs.org/ Eventually add more, and just map the labels/data correctly.
Instance Method Summary collapse
- #charts_doughnut_tag(*args) ⇒ Object
- #charts_pie_tag(*args) ⇒ Object
- #charts_tag(type, data = [], labels = [], html_options = {}) ⇒ Object
Instance Method Details
#charts_doughnut_tag(*args) ⇒ Object
7 8 9 |
# File 'app/helpers/kadmin/charts_helper.rb', line 7 def charts_doughnut_tag(*args) charts_tag('doughnut', *args) end |
#charts_pie_tag(*args) ⇒ Object
11 12 13 |
# File 'app/helpers/kadmin/charts_helper.rb', line 11 def charts_pie_tag(*args) charts_tag('pie', *args) end |
#charts_tag(type, data = [], labels = [], html_options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/kadmin/charts_helper.rb', line 15 def charts_tag(type, data = [], labels = [], = {}) = { class: 'kadmin--chart', data: { 'kadmin--chart-type': type, 'kadmin--chart-labels': labels.to_json.tr('"', '\"'), 'kadmin--chart-data': data.to_json.tr('"', '\"') } }.merge() return content_tag(:canvas, '', ) end |