Module: MetricsGraphicsRails::ViewHelpers
- Defined in:
- lib/metrics-graphics-rails/view_helpers.rb
Instance Method Summary collapse
-
#metrics_graphic_for(data, options = {}) ⇒ Object
TODO: generalize for extra options.
Instance Method Details
#metrics_graphic_for(data, options = {}) ⇒ Object
TODO: generalize for extra options
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/metrics-graphics-rails/view_helpers.rb', line 6 def metrics_graphic_for(data, = {}) @data = data json_data = data.to_json @target = .fetch(:target) @x_accessor = .fetch(:x_accessor) { :date } @y_accessor = .fetch(:y_accessor) { :value } title = .fetch(:title) description = .fetch(:description) { '' } width = .fetch(:width) { 600 } height = .fetch(:height) { 250 } @time_format = .fetch(:time_format) { '%Y-%m-%d' } @is_multiple = data.first.is_a?(Array) @extra_options = [:extra_options] || {} javascript_tag <<-SCRIPT var data = #{json_data}; #{convert_data_js} MG.data_graphic({ title: "#{title}", description: "#{description}", data: data, width: #{width}, height: #{height}, target: '#{@target}',#{} x_accessor: '#{@x_accessor}', y_accessor: '#{@y_accessor}' }); SCRIPT end |