added proper width for production chart
This commit is contained in:
@@ -6,33 +6,30 @@ use Filament\Widgets\ChartWidget;
|
||||
|
||||
class ItemOverview extends ChartWidget
|
||||
{
|
||||
protected static ?string $heading = 'Chart';
|
||||
protected static ?string $heading = 'Hourly Production';
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
// protected int|string|array $columnSpan = 'full';
|
||||
protected int|string|array $columnSpan = 12;
|
||||
|
||||
protected $listeners = ['filtersUpdated' => '$refresh'];
|
||||
// public $plantId;
|
||||
// public $lineId;
|
||||
protected static ?string $maxHeight = '300px';
|
||||
|
||||
protected $listeners = ['filtersUpdated' => '$refresh'];
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$activeFilter = $this->filter;
|
||||
// $selectPlant = session('select_plant');
|
||||
// $selectLine = session('select_line');
|
||||
|
||||
// $selectedPlant = session('selected_plant');
|
||||
// $selectedLine = session('selected_line');
|
||||
|
||||
$selectedPlant = session('selected_plant') ?? session('select_plant');
|
||||
$selectedLine = session('selected_line') ?? session('select_line');
|
||||
|
||||
|
||||
if (!$selectedPlant || !$selectedLine) {
|
||||
return [
|
||||
'datasets' => [],
|
||||
'labels' => [],
|
||||
];
|
||||
}
|
||||
if (!$selectedPlant || !$selectedLine)
|
||||
{
|
||||
return [
|
||||
'datasets' => [],
|
||||
'labels' => [],
|
||||
];
|
||||
}
|
||||
|
||||
if ($activeFilter === 'yesterday') {
|
||||
$startDate = now()->subDay()->startOfDay();
|
||||
@@ -47,8 +44,6 @@ class ItemOverview extends ChartWidget
|
||||
else if ($activeFilter === 'this_month') {
|
||||
$startDate = now()->startOfMonth();
|
||||
$endDate = now()->endOfMonth();
|
||||
|
||||
// Group records into weeks
|
||||
$groupBy = "FLOOR((EXTRACT(DAY FROM production_quantities.created_at) - 1) / 7) + 1";
|
||||
}
|
||||
else
|
||||
@@ -111,8 +106,9 @@ class ItemOverview extends ChartWidget
|
||||
$data[6] ?? 0, // Saturday
|
||||
$data[0] ?? 0, // Sunday (move to last)
|
||||
];
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hourly data (same as before)
|
||||
$allHours = array_fill(0, 24, 0);
|
||||
$data = array_replace($allHours, $query);
|
||||
@@ -150,17 +146,42 @@ class ItemOverview extends ChartWidget
|
||||
return 'line';
|
||||
}
|
||||
|
||||
// protected function getContent(): string
|
||||
// {
|
||||
// return '<div style="height: 100%;">' . $this->chart->render() . '</div>';
|
||||
// }
|
||||
// protected function getContent(): string
|
||||
// {
|
||||
// return <<<HTML
|
||||
// <div id="chart-container" style="height: 100vh; width: 100%;">
|
||||
// {$this->chart->render()}
|
||||
// </div>
|
||||
// HTML;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
'scales' => [
|
||||
'y' => [
|
||||
'beginAtZero' => true, //Start Y-axis from 0
|
||||
'beginAtZero' => true,
|
||||
'ticks' => [
|
||||
'stepSize' => 0.5,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
// 'scales' => [
|
||||
// 'y' => [
|
||||
// 'beginAtZero' => true, //Start Y-axis from 0
|
||||
// 'ticks' => [
|
||||
// 'stepSize' => 0.5,
|
||||
// ],
|
||||
// ],
|
||||
// ],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -173,7 +194,4 @@ class ItemOverview extends ChartWidget
|
||||
'this_month'=> 'This Month',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user