123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace App\Controller;
- use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\Routing\Attribute\Route;
- use Symfony\UX\Chartjs\Builder\ChartBuilderInterface;
- use Symfony\UX\Chartjs\Model\Chart;
- class DashboardController extends AbstractController
- {
- #[Route('/dashboard', name: 'app_dashboard')]
- public function index(ChartBuilderInterface $chartBuilderInterface): Response
- {
- $chart = $chartBuilderInterface->createChart(Chart::TYPE_DOUGHNUT);
- $chart->setData([
- 'labels' => ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
- 'datasets' => [
- [
- 'label' => 'My First dataset',
- 'backgroundColor' => 'rgb(255, 99, 132)',
- 'borderColor' => 'rgb(255, 99, 132)',
- 'data' => [0, 10, 5, 2, 20, 30, 45],
- ],
- ],
- ]);
- $chart->setOptions([
- 'scales' => [
- 'y' => [
- 'suggestedMin' => 0,
- 'suggestedMax' => 100,
- ],
- ],
- ]);
- return $this->render('dashboard/index.html.twig', [
- 'chart' => $chart,
- ]);
- }
- }
|