I am completely new to RoR / Ruby, and I use the Lazy High Charts gem to create some clean charts based on some database information.
I tried the answers that were provided in the previous question, but I'm still a bit confused as to how to do this.
I need to sum the amount_used and billed_amount and group by month / year (e.g. Aug / 2012)
The end result will be something like a double-axis chart with two series of “Quantity Used” and “Cost”. This information relates to a specific account_id.

Invoice table
+---------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | account_id | int(11) | YES | | NULL | | | invoice_date | varchar(255) | YES | | NULL | | | amount_used | float | YES | | NULL | | | billed_amount | float | YES | | NULL | | | comments | text | YES | | NULL | | | created_at | datetime | NO | | NULL | | | updated_at | datetime | NO | | NULL | | +---------------+--------------+------+-----+---------+----------------+
Controller Chart Code
@account = Account.find(params[:id]) @invoices = Invoice.where("account_id = #{@account.id}").order("invoice_date DESC") @h = LazyHighCharts::HighChart.new('area') do |f| f.options[:chart][:defaultSeriesType] = "area"
source share