@props(['trend']) @php use App\Reports\TrendChart; use App\Support\Money; $chart = new TrendChart($trend); $sizes = [[360, 44, 'sm:hidden'], [640, 64, 'hidden sm:block']]; $tips = collect($chart->months)->map(fn ($m) => [ 'title' => $m['title'], 'income' => Money::format($m['income']), 'expenses' => Money::format($m['expenses']), 'profit' => Money::format($m['profit']), ])->all(); @endphp {{-- Net income vs expenses by month. Colors validated: #2a78d6 / #eb6834 on white (dataviz validator, all checks pass). --}}
class('card p-4') }} x-data="{ tip: null, x: 0, tips: @js($tips), show(i, x) { this.tip = this.tips[i]; this.x = x } }">
Last {{ count($chart->months) }} months Net income Expenses
@if (! $chart->hasData())

No income or expenses in these months yet.

@else @foreach ($sizes as [$width, $padLeft, $visibility]) @php($chart = new TrendChart($trend, $width, $padLeft))
@foreach ($chart->ticks as $tick) {{ $chart->tickLabel($tick) }} @endforeach @foreach ($chart->months as $i => $month) {{ $month['label'] }} {{-- The whole month band is the hover and focus target, bigger than the bars. --}} @endforeach
income
expenses
Profit
@endforeach @endif
Show as table @foreach ($chart->months as $month) @endforeach
MonthNet incomeExpensesProfit
{{ $month['title'] }} {{ Money::format($month['income']) }} {{ Money::format($month['expenses']) }} $month['profit'] < 0])>{{ Money::format($month['profit']) }}