Added chart js plugin package and sets static label
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\Line;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\QualityValidation;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Filament\Support\RawJs;
|
||||
|
||||
class CumulativeChart extends ChartWidget
|
||||
{
|
||||
@@ -163,6 +164,15 @@ class CumulativeChart extends ChartWidget
|
||||
}
|
||||
}
|
||||
|
||||
$nonFgData = array_map(function ($value) {
|
||||
return ($value == 0 || is_null($value)) ? null : $value;
|
||||
}, $nonFgData);
|
||||
|
||||
$fgData = array_map(function ($value) {
|
||||
return ($value == 0 || is_null($value)) ? null : $value;
|
||||
}, $fgData);
|
||||
|
||||
|
||||
return [
|
||||
'labels' => $labels,
|
||||
'datasets' => array_filter([
|
||||
@@ -186,8 +196,11 @@ class CumulativeChart extends ChartWidget
|
||||
'data' => $fgData,
|
||||
// 'backgroundColor' => '#ef4444', // Red for FG
|
||||
],
|
||||
|
||||
]),
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
@@ -208,6 +221,23 @@ class CumulativeChart extends ChartWidget
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
// 'plugins' => [
|
||||
// 'datalabels' => false,
|
||||
// ],
|
||||
'plugins' => [
|
||||
'datalabels' => [
|
||||
'anchor' => 'start',
|
||||
'align' => 'start',
|
||||
'offset' => 4,
|
||||
'color' => '#000',
|
||||
'font' => [
|
||||
'weight' => 'bold',
|
||||
],
|
||||
'formatter' => RawJs::make('function(value) {
|
||||
return value;
|
||||
}'),
|
||||
],
|
||||
],
|
||||
'scales' => [
|
||||
'y' => [
|
||||
'beginAtZero' => true, //Start Y-axis from 0
|
||||
@@ -219,4 +249,12 @@ class CumulativeChart extends ChartWidget
|
||||
];
|
||||
}
|
||||
|
||||
// public static function canView(): bool
|
||||
// {
|
||||
// return request()->routeIs([
|
||||
// 'filament.pages.hourly-production',
|
||||
// 'filament.admin.resources.production-quantities.create',
|
||||
// ]);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user