@php $series = [ 'sales' => ['label' => __('Sales'), 'color' => '#6366f1'], 'purchases' => ['label' => __('Purchases'), 'color' => '#06b6d4'], 'expenses' => ['label' => __('Paid Expenses'), 'color' => '#f59e0b'], ]; $chartMax = max(1, collect($monthChartDays)->flatMap(fn ($day) => [$day['sales'], $day['purchases'], $day['expenses']])->max()); $chartMax = ceil($chartMax / 4) * 4; $dayCount = count($monthChartDays); $hasActivity = collect($monthChartDays)->contains(fn ($day) => $day['sales'] != 0 || $day['purchases'] != 0 || $day['expenses'] != 0); $chartX = fn ($index) => $dayCount === 1 ? 410 : 65 + ($index / ($dayCount - 1)) * 690; $chartY = fn ($value) => 245 - ($value / $chartMax) * 210; $compactAmount = fn ($value) => $value >= 1000000 ? round($value / 1000000, 1) . 'M' : ($value >= 1000 ? round($value / 1000, 1) . 'k' : number_format($value, 0)); @endphp

{{ __('Monthly Business Overview') }}

{{ __('Daily sales, purchases and paid expenses') }}

{{ $monthChartLabel }}
@foreach($series as $key => $config) @endforeach
{{ __('Current month business activity') }} {{ __('Amounts in rupees, from the start of this month through today. Focus or hover over a day to see exact amounts. Use the legend to toggle series.') }} @for($tick = 0; $tick <= 4; $tick++) @php($y = 245 - $tick * 52.5) {{ $compactAmount($chartMax * $tick / 4) }} @endfor {{ __('Rs.') }} @foreach($series as $key => $config) @php($points = collect($monthChartDays)->map(fn ($day, $index) => $chartX($index) . ',' . $chartY($day[$key]))->implode(' ')) @if($key === 'sales' && $dayCount > 1) @endif @foreach($monthChartDays as $index => $day) @endforeach @endforeach @foreach($monthChartDays as $index => $day) @if($index === 0 || $index === $dayCount - 1 || ($index % max(1, (int) ceil($dayCount / 7)) === 0 && $index < $dayCount - 2)) {{ $day['label'] }} @endif {{ $day['label'] }} — {{ __('Sales') }}: Rs. {{ number_format($day['sales'], 2) }} | {{ __('Purchases') }}: Rs. {{ number_format($day['purchases'], 2) }} | {{ __('Paid Expenses') }}: Rs. {{ number_format($day['expenses'], 2) }} @endforeach @if(! $hasActivity)

{{ __('No activity recorded this month yet.') }}

@endif
{{ $monthChartDays[$dayCount - 1]['label'] }} @foreach($series as $key => $config) {{ $config['label'] }}: Rs. {{ number_format($monthChartDays[$dayCount - 1][$key], 2) }} @endforeach

{{ __('Month to date') }} · {{ $periodLabel }}