Added chart js plugin package and sets static label

This commit is contained in:
dhanabalan
2025-06-27 12:46:29 +05:30
parent fea6573a7a
commit 0fc1852ea2
14 changed files with 6141 additions and 695 deletions

View File

@@ -14,7 +14,7 @@ class ItemOverview extends ChartWidget
protected int|string|array $columnSpan = '12';
protected static ?string $maxHeight = '350px';
protected static ?string $maxHeight = '400px';
protected $listeners = ['filtersUpdated' => '$refresh'];
@@ -116,6 +116,10 @@ class ItemOverview extends ChartWidget
$labels = array_map(fn ($hour) => date("g A", strtotime("$hour:00")), $shiftedKeys);
}
// $orderedData = array_map(function ($value) {
// return ($value == 0 || is_null($value)) ? null : $value;
// }, $orderedData);
return [
'datasets' => [
[
@@ -126,11 +130,11 @@ class ItemOverview extends ChartWidget
default => $isFgLine ? "Today's FG Count" : "Today's Hourly Production",
},
'data' => $orderedData,
'interaction' => [
'mode' => 'nearest',
'axis' => 'x',
'intersect' => false,
],
// 'interaction' => [
// 'mode' => 'nearest',
// 'axis' => 'x',
// 'intersect' => false,
// ],
'borderColor' => 'rgba(75, 192, 192, 1)',
'backgroundColor' => 'rgba(75, 192, 192, 0.2)',
'fill' => false,
@@ -146,10 +150,34 @@ class ItemOverview extends ChartWidget
return 'line';
}
// protected function getOptions(): array
// {
// return [
// 'scales' => [
// 'y' => [
// 'beginAtZero' => true,
// 'ticks' => [
// 'stepSize' => 0.5,
// ],
// ],
// ],
// ];
// }
protected function getOptions(): array
{
return [
'plugins' => [
'datalabels' => [
'anchor' => 'start',
'color' => '#000',
'font' => [
'weight' => 'bold',
],
'formatter' => 'function(value) { return Number(value); }',
],
],
'scales' => [
'y' => [
'beginAtZero' => true,
@@ -162,6 +190,7 @@ class ItemOverview extends ChartWidget
}
protected function getFilters(): ?array
{
return [