1
0
forked from poc/pds

chenged label position of the x axis in production order count

This commit is contained in:
dhanabalan
2025-06-27 15:24:18 +05:30
parent 72a1eca400
commit 1945e71ae1

View File

@@ -41,7 +41,7 @@ class ProductionOrderChart extends ChartWidget
if ($lineType == 'FG Line') if ($lineType == 'FG Line')
{ {
$table = 'quality_validations'; $table = 'quality_validations';
$dateColumn = 'created_at'; // adjust if your date column is named differently $dateColumn = 'created_at';
$plantColumn = 'plant_id'; $plantColumn = 'plant_id';
$lineColumn = 'line_id'; $lineColumn = 'line_id';
$orderColumn = 'production_order'; $orderColumn = 'production_order';
@@ -127,18 +127,40 @@ class ProductionOrderChart extends ChartWidget
$data[0] ?? 0, // Sunday $data[0] ?? 0, // Sunday
]; ];
} }
// else
// {
// $allHours = array_fill(0, 24, 0);
// $data = array_replace($allHours, $query);
// $shiftedKeys = array_merge(range(9, 23), range(0, 8));
// $orderedData = array_map(fn($hour) => $data[$hour], $shiftedKeys);
// $labels = array_map(fn ($hour) => date("g A", strtotime("$hour:00")), $shiftedKeys);
// }
else else
{ {
$allHours = array_fill(0, 24, 0); $allHours = array_fill(0, 24, 0);
$data = array_replace($allHours, $query); $data = array_replace($allHours, $query);
$shiftedKeys = array_merge(range(8, 23), range(0, 8)); // Shift counts - move each hour's count to the next hour
$orderedData = array_map(fn($hour) => $data[$hour], $shiftedKeys); $shiftedData = [];
foreach ($data as $hour => $count) {
$labels = array_map(fn ($hour) => date("g A", strtotime("$hour:00")), $shiftedKeys); $nextHour = ($hour + 1) % 24;
$shiftedData[$nextHour] = $count;
} }
$orderedData = array_map(function ($value) { // Order from 9AM to 8AM next day
$shiftedKeys = array_merge(range(9, 23), range(0, 8));
$orderedData = array_map(fn($hour) => $shiftedData[$hour] ?? 0, $shiftedKeys);
// Create labels
$labels = array_map(function($hour) {
return date("g A", strtotime("$hour:00"));
}, $shiftedKeys);
}
$orderedData = array_map(function ($value)
{
return ($value == 0 || is_null($value)) ? null : $value; return ($value == 0 || is_null($value)) ? null : $value;
}, $orderedData); }, $orderedData);
@@ -183,12 +205,9 @@ class ProductionOrderChart extends ChartWidget
return [ return [
'plugins' => [ 'plugins' => [
'datalabels' => [ 'datalabels' => [
// 'anchor' => 'start',
// 'align' => 'start',
// 'offset' => 1,
'anchor' => 'start', 'anchor' => 'start',
'align' => 'start', 'align' => 'start',
'offset' => 8, 'offset' => -15,
'color' => '#000', 'color' => '#000',
'font' => [ 'font' => [
'weight' => 'bold', 'weight' => 'bold',