Added chart js plugin package and sets static label
This commit is contained in:
@@ -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 [
|
||||
|
||||
Reference in New Issue
Block a user