{{ __('filament-activity-log::activity.widgets.heatmap.heading') }} @php $heatmap = $this->getData(); $data = $heatmap['data']; $max = $heatmap['max']; $startDate = now()->subDays(365)->startOfWeek(); $endDate = now(); // Calculate months with smart spacing to avoid overlap $months = []; $currentMonth = $startDate->isoFormat('MMM'); $months[] = ['name' => $currentMonth, 'week_index' => 0]; $lastLabelWeek = 0; $dt = $startDate->copy(); for ($weekIndex = 0; $weekIndex < 52; $weekIndex++) { $month = $dt->addWeek()->isoFormat('MMM'); if ($month !== $currentMonth) { // Only add label if it's been at least 4 weeks since the last one if (($weekIndex - $lastLabelWeek) >= 4) { $months[] = ['name' => $month, 'week_index' => $weekIndex]; $lastLabelWeek = $weekIndex; $currentMonth = $month; } } } // Grid cell dimensions for label calculation $cellSize = 11; // px $gap = 3; // px $weekWidth = $cellSize + $gap; @endphp
@foreach ($months as $month)
{{ $month['name'] }}
@endforeach
@foreach (range(0, 52) as $week) @foreach (range(0, 6) as $day) @php $currentDate = $startDate->copy()->addWeeks($week)->addDays($day); $dateString = $currentDate->toDateString(); $count = $data[$dateString] ?? 0; $intensity = $count > 0 ? (int) ceil(($count / $max) * 4) : 0; // Universal colors (subtler empty state) $bg = match ($intensity) { 0 => 'rgba(128, 128, 128, 0.1)', // More subtle empty state 1 => '#22c55e40', 2 => '#22c55e80', 3 => '#22c55ebf', 4 => '#22c55e', default => 'rgba(128, 128, 128, 0.1)', }; $tooltip = trans_choice('filament-activity-log::activity.widgets.heatmap.tooltip', $count, [ 'date' => $currentDate->isoFormat('ll'), ]); @endphp @if ($currentDate <= $endDate)
@else
@endif @endforeach @endforeach
{{ __('filament-activity-log::activity.widgets.heatmap.less') }}
{{ __('filament-activity-log::activity.widgets.heatmap.more') }}