Class: Chartify::PieChart

Inherits:
ChartBase show all
Defined in:
lib/chartify/pie_chart.rb

Direct Known Subclasses

WebChart::GoogleChart::PieChart

Instance Attribute Summary

Attributes inherited from ChartBase

#columns, #data, #label_column, #title

Instance Method Summary collapse

Methods inherited from ChartBase

#add_row, evaluate_js, #render_chart

Constructor Details

#initializePieChart

Returns a new instance of PieChart.



13
14
15
16
# File 'lib/chartify/pie_chart.rb', line 13

def initialize
  super
  self.columns = ['Title', 'Value']
end

Instance Method Details

#to_blobObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/chartify/pie_chart.rb', line 18

def to_blob
  g = instantiate_gruff(:pie)

  data.each do |row|
    if row.kind_of?(Array)
      key, val = row[0], row[1]
    else
      key, val = row.key, row.val
    end
    g.data(key, val)
  end
  g.to_blob
end