Module: Effective::EffectiveDatatable::Dsl::Charts

Included in:
Datatable
Defined in:
app/models/effective/effective_datatable/dsl/charts.rb

Instance Method Summary collapse

Instance Method Details

#chart(name, type, options = {}, &block) ⇒ Object

Instance Methods inside the charts do .. end block



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/effective/effective_datatable/dsl/charts.rb', line 6

def chart(name, type, options = {}, &block)

  options[:title] ||= (options[:label] || name.to_s.titleize)
  options[:legend] = 'none' if options[:legend] == false

  (@charts ||= HashWithIndifferentAccess.new)[name] = {
    name: name,
    type: type,
    partial: options.delete(:partial),
    options: options,
    block: (block if block_given?)
  }
end