Skip to content

Instantly share code, notes, and snippets.

@nickbuddendotcom
Created May 5, 2013 15:41
Show Gist options
  • Save nickbuddendotcom/5521172 to your computer and use it in GitHub Desktop.
Save nickbuddendotcom/5521172 to your computer and use it in GitHub Desktop.
def index
@weights = current_user.weights.all
@startdate = 30.days.ago.to_date
@pounds = (30.days.ago.to_date..Date.today).map { |date| Weight.pounds_on(date).to_f }
@h = LazyHighCharts::HighChart.new('graph') do |f|
f.options[:title][:text] = " "
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 => @startdate, :name => 'Weight (lbs)', :color => "#2cc9c5", :data => @pounds )
f.options[:xAxis] = {:minTickInterval => 1, :type => "datetime", :dateTimeLabelFormats => { day: "%b %e"}, :title => { :text => nil }, :labels => { :enabled => true } }
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @weights }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment