Module: RailsCharts::Helpers

Defined in:
lib/rails_charts/helpers.rb

Instance Method Summary collapse

Instance Method Details

#area_chart(data, options = {}) ⇒ Object



39
40
41
# File 'lib/rails_charts/helpers.rb', line 39

def area_chart(data, options = {})
  generate_rails_chart AreaChart, data, options
end

#bar_chart(data, options = {}) ⇒ Object



11
12
13
# File 'lib/rails_charts/helpers.rb', line 11

def bar_chart(data, options = {})
  generate_rails_chart BarChart, data, options
end

#calendar_chart(data, options = {}) ⇒ Object



47
48
49
# File 'lib/rails_charts/helpers.rb', line 47

def calendar_chart(data, options = {})
  generate_rails_chart CalendarChart, data, options
end

#candlestick_chart(data, options = {}) ⇒ Object



59
60
61
# File 'lib/rails_charts/helpers.rb', line 59

def candlestick_chart(data, options = {})
  generate_rails_chart CandlestickChart, data, options
end

#custom_chart(options = {}) ⇒ Object



63
64
65
# File 'lib/rails_charts/helpers.rb', line 63

def custom_chart(options = {})
  generate_rails_chart CustomChart, [], options
end

#donut_chart(data, options = {}) ⇒ Object



31
32
33
# File 'lib/rails_charts/helpers.rb', line 31

def donut_chart(data, options = {})
  generate_rails_chart DonutChart, data, options
end

#funnel_chart(data, options = {}) ⇒ Object



51
52
53
# File 'lib/rails_charts/helpers.rb', line 51

def funnel_chart(data, options = {})
  generate_rails_chart FunnelChart, data, options
end

#gauge_chart(data, options = {}) ⇒ Object



55
56
57
# File 'lib/rails_charts/helpers.rb', line 55

def gauge_chart(data, options = {})
  generate_rails_chart GaugeChart, data, options
end

#generate_rails_chart(klass, data, options = {}) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rails_charts/helpers.rb', line 67

def generate_rails_chart(klass, data, options = {})
  klass = klass.new(data, options)
  if options[:code]
    tag.textarea(row: 20, cols: 80, style: 'width: 100%; height: 300px') do
      klass.js_code
    end
  else
    # tag.pre(debug(data.inspect)) +
    # tag.textarea(row: 20, cols: 80, style: 'width: 100%; height: 300px') do
    #   klass.js_code
    # end +
    raw(klass.js_code)
  end
end

#line_chart(data, options = {}) ⇒ Object



7
8
9
# File 'lib/rails_charts/helpers.rb', line 7

def line_chart(data, options = {})
  generate_rails_chart LineChart, data, options
end

#parallel_chart(data, options = {}) ⇒ Object



27
28
29
# File 'lib/rails_charts/helpers.rb', line 27

def parallel_chart(data, options = {})
  generate_rails_chart ParallelChart, data, options
end

#pie_chart(data, options = {}) ⇒ Object



19
20
21
# File 'lib/rails_charts/helpers.rb', line 19

def pie_chart(data, options = {})
  generate_rails_chart PieChart, data, options
end

#radar_chart(data, options = {}) ⇒ Object



43
44
45
# File 'lib/rails_charts/helpers.rb', line 43

def radar_chart(data, options = {})
  generate_rails_chart RadarChart, data, options
end

#sankey_chart(data, options = {}) ⇒ Object



35
36
37
# File 'lib/rails_charts/helpers.rb', line 35

def sankey_chart(data, options = {})
  generate_rails_chart SankeyChart, data, options
end

#scatter_chart(data, options = {}) ⇒ Object



23
24
25
# File 'lib/rails_charts/helpers.rb', line 23

def scatter_chart(data, options = {})
  generate_rails_chart ScatterChart, data, options
end

#stacked_bar_chart(data, options = {}) ⇒ Object



15
16
17
# File 'lib/rails_charts/helpers.rb', line 15

def stacked_bar_chart(data, options = {})
  generate_rails_chart StackedBarChart, data, options
end