Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

how to create a pie chart in MVC

I am working on creating a pie chart the reflects my table. I'm coding in ruby on rails. Please any help or advice Inside my dashboard/index.html.erb The pie chart I'm trying to display is below: <%= pie_chart @dashboard_broker.group(:company_id ).order(actual_amount: :desc).limit(5).sum(actual_amount) %>

Below is the table code that works and Im trying to display on the company name and actual amount: <% @dashboard_broker.each do |db| %> <tr> <td><%= db.deal.description %></td> <td><%= link_to "Details", controller: "deals", action: "show", id: db.id %></td> <td><%= db.deal.company.name %></td> <td><%= db.percentage %></td> <td><%= number_to_currency(db.expected_amount) %></td> <td><%= number_to_currency(db.calculate_actual_amount) %></td> <td><%= db.broker.broker_full_name %></td> </tr> <% end %>

Below is my dashboard_controller def index @dashboard_commission = Commission.all @dashboard_sub_renewal = Subscription.where("enrollment_date between ? and ?", Date.today - 12.months, Date.today - 9.months).order(:enrollment_date).first(15) @dashboard_contact = Contact.all

@dashboard_broker = Commission.where('broker_id == ?', current_user)
@current_client = Company.where('broker_id == ?', current_user)
@current_deal = Deal.where('broker_id == ?', current_user)

end

I forgot to add the pie chart code and Im using chartkick gem

<%= pie_chart @dashboard_broker.group(:company_id ).order(actual_amount: :desc).limit(5).sum(actual_amount).limit(5).sum(:actual_amount) %>