Navigate to spice edit page on chart bar click
Deploy / deploy (push) Successful in 15s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Malek TellissiandClaude Sonnet 4.6 committed 2026-09-12 22:38:39 +02:00
1 parent fb19e9a579
commit 092a78e306
1 file changed
+17 -3
@@ -70,11 +70,25 @@ class SpiceChart extends ApexChartWidget {
} }
protected function extraJsOptions(): ?RawJs { protected function extraJsOptions(): ?RawJs {
return RawJs::make(<<<'JS' $urls = \App\Models\Spice::all()
->map(fn ($s) => \App\Filament\User\Resources\SpiceResource::getUrl('edit', ['record' => $s->id]))
->values()
->toJson();
return RawJs::make(<<<JS
{ {
chart: {
events: {
dataPointSelection: function(event, chartContext, config) {
var urls = {$urls};
var url = urls[config.dataPointIndex];
if (url) window.location.href = url;
}
}
},
xaxis: { xaxis: {
labels: { labels: {
formatter: function (val, timestamp, opts) { formatter: function (val) {
return val.replace('( ', '(') return val.replace('( ', '(')
} }
} }
@@ -86,7 +100,7 @@ class SpiceChart extends ApexChartWidget {
}, },
dropShadow: { dropShadow: {
enabled: true enabled: true
}, }
} }
} }
JS); JS);