Class: QueryReport::Chart::PieChart

Inherits:
ChartBase
  • Object
show all
Defined in:
lib/query_report/chart/pie_chart.rb

Instance Attribute Summary

Attributes inherited from ChartBase

#columns, #data, #options, #title

Instance Method Summary collapse

Methods inherited from ChartBase

#add

Constructor Details

#initialize(title, query, options = {}) ⇒ PieChart

Returns a new instance of PieChart.



16
17
18
# File 'lib/query_report/chart/pie_chart.rb', line 16

def initialize(title, query, options={})
  super(title, query, options)
end

Instance Method Details

#prepare_visualrObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/query_report/chart/pie_chart.rb', line 20

def prepare_visualr
  @data_table = GoogleVisualr::DataTable.new

  ##### Adding column header #####
  @data_table.new_column('string', 'Item')
  @data_table.new_column('number', 'Value')
  ##### Adding column header #####

  @columns.each_with_index do |column, i|
    @data_table.add_row([column.title, @data[i]])
  end

  options = {:title => title, backgroundColor: 'transparent'}.merge(@options)
  GoogleVisualr::Interactive::PieChart.new(@data_table, options)
end

#to_blobObject



36
37
38
# File 'lib/query_report/chart/pie_chart.rb', line 36

def to_blob
  super(:pie)
end