Module: Chartism::Helper
- Defined in:
- lib/chartism/helper.rb
Instance Method Summary collapse
-
#chart(chartism, options = {}) ⇒ Object
Options include: - id - class.
Instance Method Details
#chart(chartism, options = {}) ⇒ Object
Options include:
- id
- class
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/chartism/helper.rb', line 8 def chart chartism, ={} data_json = chartism.data.to_json = chartism..to_json id = .fetch :id, "chartism-#{SecureRandom.hex(6)}" classes = ( ['ct-chart'] + Array([:class]) ).join(' ') %Q[ <div class="#{classes}" id="#{id}"></div> <script> (function() { var data = #{data_json}; var options = #{options_json}; new Chartist.#{chart_type(chartism)}("##{id}", data, options); })(); </script> ].html_safe end |