Class: Chartify::AreaChart

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

Direct Known Subclasses

WebChart::GoogleChart::AreaChart

Instance Attribute Summary

Attributes inherited from ChartBase

#columns, #data, #label_column, #title

Instance Method Summary collapse

Methods inherited from ChartBase

#add_row, evaluate_js, #initialize, #render_chart

Constructor Details

This class inherits a constructor from Chartify::ChartBase

Instance Method Details

#to_blobObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/chartify/area_chart.rb', line 15

def to_blob
  raise 'Need to specify label_column' unless label_column.present?
  g = instantiate_gruff(:area)

  columns.each do |column|
    if column.kind_of?(Array)
      key, text = column[0], column[1]
    else
      key, text = column, column.to_s.humanize
    end

    g.data(text, data_for_column(key))
  end

  labels = {}
  data_for_column(label_column).each_with_index do |label, index|
    labels[index] = label.to_s
  end

  g.labels = labels
  g.to_blob
end