get(); $data = []; $labels = []; $count = $spices->count(); foreach ($spices as $spice) { if ($spice->unit === 'grams') { $data[] = round($spice->quantity / 1000, 2); $labels[] = $spice->name . ' (kg)'; } elseif ($spice->unit === 'pieces') { $data[] = $spice->quantity; $labels[] = $spice->name . ' (Stück)'; } elseif ($spice->unit === 'liter') { $data[] = $spice->quantity; $labels[] = $spice->name . ' (Liter)'; } else { $data[] = $spice->quantity; $labels[] = $spice->name . ' (' . ucfirst($spice->unit) . ')'; } } return [ 'chart' => [ 'type' => 'bar', 'height' => 300, 'width' => max(600, $count * 120), ], 'series' => [ [ 'name' => 'Bestand', 'data' => $data, ], ], 'xaxis' => [ 'categories' => $labels, 'labels' => ['style' => ['fontFamily' => 'inherit']], ], 'yaxis' => [ 'labels' => ['style' => ['fontFamily' => 'inherit']], ], 'colors' => ['#f59e0b'], 'plotOptions' => [ 'bar' => ['borderRadius' => 3, 'horizontal' => false], ], ]; } protected function extraJsOptions(): ?RawJs { $urls = Js::from( Spice::orderBy('id') ->get() ->map(fn ($spice) => url('/dashboard/rohstoffe/' . $spice->id . '/edit')) ->values() ->toArray() ); return RawJs::make(<<