© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago
umair

how to add percentage % in pie chart

@Bezhan #pie-chart-table-column


$totalOrders = DB::table('orders')
->whereNotNull('order_source')
->count();

$ordersBySource = DB::table('orders')
->select('order_source', DB::raw('COUNT(*) as count'))
->whereNotNull('order_source')
->groupBy('order_source')
->pluck('count', 'order_source')
->toArray();

$ordersWithPercentage = [];

foreach ($ordersBySource as $source => $count) {
$percentage = ($count / $totalOrders) * 100;
$ordersWithPercentage[$source] = $percentage;
}

return [
'datasets' => [
[
'label' => 'Order Sources',
'data' => array_values($ordersWithPercentage),
'backgroundColor' => [
'rgb(255, 99, 132)',
'rgb(54, 162, 235)',
'rgb(255, 205, 86)'
],

],

],
'labels' => array_keys($ordersWithPercentage),
];

here i also tried to attached percentage symbol but code i not working
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

pie chart
FilamentFFilament / ❓┊help
3y ago
in Apex Charts not showing filter in pie chart
FilamentFFilament / ❓┊help
3y ago
Adding percentages to pie chart
FilamentFFilament / ❓┊help
2y ago
How to remove X and Y in pie chart
FilamentFFilament / ❓┊help
3y ago