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

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

Instance Method Summary collapse

Instance Method Details

#chart(name, as = 'BarChart', label: nil, legend: true, partial: nil, **options, &compute) ⇒ Object

Instance Methods inside the charts do .. end block



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

def chart(name, as = 'BarChart', label: nil, legend: true, partial: nil, **options, &compute)
  raise 'expected a block returning an Array of Arrays' unless block_given?

  datatable._charts[name.to_sym] = {
    as: as,
    compute: compute,
    name: name,
    options: { label: (label || name.to_s.titleize), legend: (legend || 'none') }.merge(options),
    partial: partial || '/effective/datatables/chart'
  }
end