Sha256: a8b8b73eff578e317d0b2ec27997daca28319390942187d00ecff889b8ca091e
Contents?: true
Size: 775 Bytes
Versions: 2
Compression:
Stored size: 775 Bytes
Contents
module Grafico module Helpers GRAPH_TYPES = %w[LineGraph AreaGraph StackGraph StreamGraph BarGraph StackedBarGraph HorizontalBarGraph SparkLine SparkBar] def graph_tag(graph_type, element, data, options = {}) args = [] args << data.to_json args << options.to_json unless options.empty? javascript_tag "var #{options[:variable_name] || (element + graph_type)} = new Grafico.#{graph_type}($('#{element}'), #{args.join(',')});" end def self.included(receiver) GRAPH_TYPES.each do |graph| receiver.instance_eval do define_method(:"#{graph.underscore}_tag") do |e, d, *opts| opts = opts.first || Hash.new graph_tag(graph, e, d, opts) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grafico-0.2.5 | lib/grafico/helpers.rb |
grafico-0.2.4 | lib/grafico/helpers.rb |