Sha256: 4207469c4bfddfddb479d777f55c5aac375fce82ab8db4e6310d1d74e9f325d5

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

// If the container element doesn't already exist, create it
var container = add_container_if_needed('<%= container %>', <%= chart.width %>, <%= chart.height %>);

<% if chart.loading_indicator? %>
  add_loading_indicator(container, <%= chart.width %>, <%= chart.height %>, <%= builder.to_js(:chart_data_loading) %>, '<%= escape_javascript asset_path('amcharts/loading.gif') %>');
<% end %>

<% if chart.legend_div %>
  add_legend_div('<%= chart.legend_div == true ? "#{container}_legend" : chart.legend_div %>', container);
<% end %>

AmCharts.ready(function() {
  var chart_data = <%= builder.to_js(chart.data) %>;
  var chart = new <%= chart.amchart_type %>;

  chart.dataProvider = chart_data;
  chart.categoryField = '<%= chart.category_field %>';
  chart.pathToImages = '<%= escape_javascript asset_path('amcharts/') %>';

  <% builder.render_settings(chart, 'chart') %>

  <% builder.render_data %>

  <% builder.render_legend %>

  <% builder.render_component(chart.category_axis, name: :category_axis, js_object: 'chart.categoryAxis', method: false) %>
  <% builder.render_component(chart.value_axes, name: :value_axis) %>
  <% builder.render_component(chart.cursor, name: :chart_cursor) %>
  <% builder.render_component(chart.scrollbar, name: :chart_scrollbar) %>

  <% builder.render_title %>

  <% builder.render_listeners %>

  chart.write('<%= container %>');
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
amcharts.rb-3.1.1.1 app/views/amcharts/chart_builder.erb
amcharts.rb-3.1.1.0 app/views/amcharts/chart_builder.erb