Sha256: 2c2f00a4b7875b63032b733ee5e9904c84e6bfc197779b9d603f8529fe26d5cc

Contents?: true

Size: 866 Bytes

Versions: 9

Compression:

Stored size: 866 Bytes

Contents

module AmCharts
  module AmChartsHelper
    def amchart(chart, container)
      # Load necessary JS and CSSfiles, without loading one more than once
      @loaded_amchart_files ||= { js: [], css: []}

      js_files = ['amcharts', "amcharts/#{chart.type}"] - @loaded_amchart_files[:js]
      css_files = ['amcharts'] - @loaded_amchart_files[:css]

      @loaded_amchart_files[:js] += js_files
      @loaded_amchart_files[:css] += css_files

      content_for(:javascript) { javascript_include_tag(*js_files) }
      content_for(:stylesheets) { stylesheet_link_tag(*css_files) }

      # Render the chart builder
      builder = AmCharts::ChartBuilder.new(chart, self)
      chart.container = container
      javascript_tag do
        builder.render_js('chart_builder', template_type: :file, locals: { chart: chart, container: container })
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
amcharts.rb-3.4.7.2 app/helpers/amcharts/amcharts_helper.rb
amcharts.rb-3.4.7.1 app/helpers/amcharts/amcharts_helper.rb
amcharts.rb-3.4.7.0 app/helpers/amcharts/amcharts_helper.rb
amcharts.rb-3.2.0.2 app/helpers/amcharts/amcharts_helper.rb
amcharts.rb-3.2.0.1 app/helpers/amcharts/amcharts_helper.rb
amcharts.rb-3.2.0.0 app/helpers/amcharts/amcharts_helper.rb
amcharts.rb-3.1.1.3 app/helpers/amcharts/amcharts_helper.rb
amcharts.rb-3.1.1.1 app/helpers/amcharts/amcharts_helper.rb
amcharts.rb-3.1.1.0 app/helpers/amcharts/amcharts_helper.rb