umair
umair
FFilament
Created by umair on 2/16/2024 in #❓┊help
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
1 replies
FFilament
Created by umair on 12/19/2023 in #❓┊help
how we set table Widgets permission using shield
i want when user give permission than Widgets display otherwise not display
4 replies