1
0
forked from poc/pds

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

@@ -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',
// ]);
// }
}