class Integral::ChartRenderer::Line

www.chartjs.org/samples/latest/charts/line.html

Private Instance Methods

process_data() click to toggle source

Line will fail if no 'period' option is supplied throw wrong argument error or w.e

# File lib/integral/chart_renderer/line.rb, line 18
def process_data
  raw_data = @dataset.map { |item| item[:scope].group_by_day(:created_at, last: 7, current: false).count }
  raw_data.map(&:values)
end
respond_with_chart(data) click to toggle source
# File lib/integral/chart_renderer/line.rb, line 7
def respond_with_chart(data)
  labels = (1..7).collect { |i| (Date.today - i.day).strftime('%a') }.join(',')
  locals = {
    data: data,
    dataset: @dataset,
    labels: labels
  }
  render_partial('line', locals)
end