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