Sha256: 240dd27286454fe6e845f5b5ea37f5f2ffa57c86677750ffb5e7c30d0a1d7538
Contents?: true
Size: 1.14 KB
Versions: 8
Compression:
Stored size: 1.14 KB
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}"] if chart.export? js_files.concat(%w(amcharts/exporting/amexport amcharts/exporting/rgbcolor amcharts/exporting/canvg amcharts/exporting/filesaver)) js_files.concat(%w(amcharts/exporting/jspdf amcharts/exporting/jspdf.plugin.addimage)) if chart.export.pdf? end js_files -= @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
8 entries across 8 versions & 1 rubygems