Module: ZTK::GoogleChart::Base::ArrayToDataTable

Included in:
ZTK::GoogleChart::Base
Defined in:
lib/ztk/google_chart/base/array_to_data_table.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) array_to_data_table(data)



7
8
9
10
11
12
13
14
# File 'lib/ztk/google_chart/base/array_to_data_table.rb', line 7

def array_to_data_table(data)
  @chart_method = :array_to_data_table
  @chart_data = data

  config.ui.logger.info { "array_to_data_table(#{data.inspect})" }

  @chart_data
end

- (Object) array_to_data_table_function



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ztk/google_chart/base/array_to_data_table.rb', line 16

def array_to_data_table_function
  <<-EOCHART
  function #{@chart_draw_tag}() {

    #{@chart_data_tag} = new google.visualization.arrayToDataTable(
      #{@chart_data.to_json}
    );

    var #{@chart_options_tag} = #{JSON.pretty_generate(@chart_options)};

    #{@chart_name_tag} = new google.visualization.#{@chart_type_tag}(document.getElementById('#{@chart_div_tag}'));
    #{@chart_name_tag}.draw(#{@chart_data_tag}, #{@chart_options_tag});
  }
EOCHART
end

- (Object) array_to_data_table_render



32
33
34
35
36
# File 'lib/ztk/google_chart/base/array_to_data_table.rb', line 32

def array_to_data_table_render
  body do
    array_to_data_table_function
  end
end