mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Add pie chart for asset/debt allocation in dashboard view (#666)
* Add pie chart for asset/debt allocation in dashboard view * Fix lint issue * Fix z-index issue with tooltip under pie chart * Fix spacing of dashboard charts
This commit is contained in:
parent
8a29725562
commit
1f6e83ee91
7 changed files with 225 additions and 16 deletions
17
app/helpers/value_groups_helper.rb
Normal file
17
app/helpers/value_groups_helper.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
module ValueGroupsHelper
|
||||
def value_group_pie_data(value_group)
|
||||
value_group.children
|
||||
.map do |child|
|
||||
{
|
||||
label: to_accountable_title(Accountable.from_type(child.name)),
|
||||
percent_of_total: child.percent_of_total.round(1).to_f,
|
||||
value: child.sum.amount.to_f,
|
||||
currency: child.sum.currency.iso_code,
|
||||
bg_color: accountable_bg_class(child.name),
|
||||
fill_color: accountable_fill_class(child.name)
|
||||
}
|
||||
end
|
||||
.filter { |child| child[:value] > 0 }
|
||||
.to_json
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue