I'm fairly new to rails and I'm trying to set the pointStart date in lazy_high_charts to pull the created_at date from my database table. I get the following error when trying to format the date and I'm not sure why:
undefined method 'year' for "Nov 13, 2012":String
Here's my controller#index:
def index
authorize! :index, @user, :message => 'Not authorized as an administrator.'
@date = User.pluck(:created_at).first
@count = User.pluck(:sign_in_count)
@h = LazyHighCharts::HighChart.new('graph') do |f|
f.options[:title][:text] = "Number of Logins"
f.options[:chart][:defaultSeriesType] = "area"
f.options[:chart][:inverted] = false
f.options[:chart][:zoomType] = 'x'
f.options[:legend][:layout] = "horizontal"
f.options[:legend][:borderWidth] = "0"
f.series(:pointInterval => 1.day, :pointStart => @date.strftime("%b %d, %Y"), :name => 'Logins', :color => "#b00000", :data => @count)
f.options[:xAxis] = { :minTickInterval => 24 * 3600 * 1000, :type => "datetime", :dateTimeLabelFormats => { day: "%b %e"}, :title => { :text => nil }, :labels => { :enabled => true } }
end
end
I've been messing with it for a while and this is the closest I could get.
Your are passing a string where you should be passing a date.
You might try this:
f.series(:pointInterval => 1.day, :pointStart => @date, :name => 'Logins', :color => "#b00000", :data => @count)