diff --git a/app/Filament/Widgets/ItemOverview.php b/app/Filament/Widgets/ItemOverview.php index 34a33985..25b7c3a7 100644 --- a/app/Filament/Widgets/ItemOverview.php +++ b/app/Filament/Widgets/ItemOverview.php @@ -7,6 +7,7 @@ use Filament\Support\Assets\Js; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; use Illuminate\Contracts\View\View; +use Illuminate\Support\HtmlString; class ItemOverview extends ChartWidget { @@ -139,6 +140,11 @@ class ItemOverview extends ChartWidget }, $shiftedKeys); } + $planData = array_map( + fn ($quantity) => round($quantity / 22.5, 2), + $orderedData + ); + return [ 'datasets' => [ [ @@ -159,6 +165,19 @@ class ItemOverview extends ChartWidget 'fill' => false, 'tension' => 0.3, ], + [ + 'label' => match ($activeFilter) { + 'this_week' => $isFgLine ? 'Daily FG Count This Week' : 'Daily Production This Week', + 'this_month' => $isFgLine ? 'Weekly FG Count This Month' : 'Weekly Production This Month', + 'yesterday' => $isFgLine ? "Yesterday's FG Count" : "Yesterday's Hourly Production", + default => $isFgLine ? "Today's FG Count" : "Today's Hourly Production", + }, + 'data' => $planData, + 'borderColor' => 'rgba(255, 99, 132, 1)', + 'backgroundColor' => 'rgba(75, 192, 192, 0.2)', + 'fill' => false, + 'tension' => 0.3, + ], ], 'labels' => $labels, ]; @@ -169,21 +188,6 @@ class ItemOverview extends ChartWidget return 'line'; } - // protected function getOptions(): array - // { - // return [ - - // 'scales' => [ - // 'y' => [ - // 'beginAtZero' => true, - // 'ticks' => [ - // 'stepSize' => 0.5, - // ], - // ], - // ], - - // ]; - // } protected function getOptions(): array { return [ @@ -210,6 +214,41 @@ class ItemOverview extends ChartWidget ]; } +// public function getHeading(): HtmlString|string|null +// { +// // Detect selected line & type +// $selectedLine = session('selected_line') ?? session('select_line'); +// $line = \App\Models\Line::find($selectedLine); +// $isFgLine = $line?->type == 'FG Line'; + +// // Dynamic title and icon +// $title = $isFgLine ? 'FG Line Production' : 'Total Production'; +// $titleColor = $isFgLine ? '#16a34a' : '#1e40af'; +// //$iconColor = $isFgLine ? 'text-green-500' : 'text-blue-500'; +// $iconColor = $isFgLine ? 'text-green-500' : 'text-blue-500'; +// //$textColor = $isFgLine ? '#16a34a' : '#3b82f6'; +// $textColor = $isFgLine ? '#0f766e' : '#b45309'; +// $iconSvg = ' +// +// '; + +// $count = number_format($this->totalCount ?? 0); + +// return new HtmlString(' +//
' . e($title) . '
+//