Erster Upload

This commit is contained in:
Malek Tellissi
2026-09-11 01:17:47 +02:00
commit 400172cdde
171 changed files with 18844 additions and 0 deletions
@@ -0,0 +1,94 @@
<?php
namespace App\Filament\User\Resources\SpiceResource\Widgets;
use Leandrocfe\FilamentApexCharts\Widgets\ApexChartWidget;
use Filament\Support\RawJs;
use App\Models\Spice;
class SpiceChart extends ApexChartWidget {
protected static ?string $chartId = 'spiceChart';
protected static ?string $heading = 'Rohstoffmengen im Lager';
protected function getOptions(): array {
$data = Spice::all();
$data_array = [];
$labels = [];
foreach ($data as $label) {
if ($label->unit == 'grams') {
$data_array[] = round($label->quantity / 1000, 2);
$labels[] = $label->name . ' (kg)';
} else {
$data_array[] = $label->quantity;
if ($label->unit == 'pieces') {
$labels[] = $label->name . ' (Stück)';
} elseif ($label->unit == 'liter') {
$labels[] = $label->name . ' (Liter)';
} else {
$labels[] = $label->name . ' (' . ucfirst($label->unit) . ')';
}
}
}
return [
'chart' => [
'type' => 'bar',
'height' => 300,
],
'series' => [
[
'name' => 'BasicBarChart',
'data' => $data_array,
],
],
'xaxis' => [
'categories' => $labels,
'labels' => [
'style' => [
'fontFamily' => 'inherit',
],
],
],
'yaxis' => [
'labels' => [
'style' => [
'fontFamily' => 'inherit',
],
],
],
'colors' => ['#f59e0b'],
'plotOptions' => [
'bar' => [
'borderRadius' => 3,
'horizontal' => false,
],
],
];
}
protected function extraJsOptions(): ?RawJs {
return RawJs::make(<<<'JS'
{
xaxis: {
labels: {
formatter: function (val, timestamp, opts) {
return val.replace('( ', '(')
}
}
},
dataLabels: {
enabled: true,
formatter: function (val, opt) {
return val+''+opt.w.globals.labels[opt.dataPointIndex].match(/\((.*?)\)/)[1]
},
dropShadow: {
enabled: true
},
}
}
JS);
}
}