chenged label position of the x axis in production order count
This commit is contained in:
@@ -41,7 +41,7 @@ class ProductionOrderChart extends ChartWidget
|
||||
if ($lineType == 'FG Line')
|
||||
{
|
||||
$table = 'quality_validations';
|
||||
$dateColumn = 'created_at'; // adjust if your date column is named differently
|
||||
$dateColumn = 'created_at';
|
||||
$plantColumn = 'plant_id';
|
||||
$lineColumn = 'line_id';
|
||||
$orderColumn = 'production_order';
|
||||
@@ -127,18 +127,40 @@ class ProductionOrderChart extends ChartWidget
|
||||
$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
|
||||
{
|
||||
$allHours = array_fill(0, 24, 0);
|
||||
$data = array_replace($allHours, $query);
|
||||
|
||||
$shiftedKeys = array_merge(range(8, 23), range(0, 8));
|
||||
$orderedData = array_map(fn($hour) => $data[$hour], $shiftedKeys);
|
||||
// Shift counts - move each hour's count to the next hour
|
||||
$shiftedData = [];
|
||||
foreach ($data as $hour => $count) {
|
||||
$nextHour = ($hour + 1) % 24;
|
||||
$shiftedData[$nextHour] = $count;
|
||||
}
|
||||
|
||||
$labels = array_map(fn ($hour) => date("g A", strtotime("$hour:00")), $shiftedKeys);
|
||||
// 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) {
|
||||
$orderedData = array_map(function ($value)
|
||||
{
|
||||
return ($value == 0 || is_null($value)) ? null : $value;
|
||||
}, $orderedData);
|
||||
|
||||
@@ -183,12 +205,9 @@ class ProductionOrderChart extends ChartWidget
|
||||
return [
|
||||
'plugins' => [
|
||||
'datalabels' => [
|
||||
// 'anchor' => 'start',
|
||||
// 'align' => 'start',
|
||||
// 'offset' => 1,
|
||||
'anchor' => 'start',
|
||||
'align' => 'start',
|
||||
'offset' => 8,
|
||||
'offset' => -15,
|
||||
'color' => '#000',
|
||||
'font' => [
|
||||
'weight' => 'bold',
|
||||
|
||||
Reference in New Issue
Block a user