countFilmsVusBy($this->getUser()); $filmsFavoris = $filmRepository->countFilmsFavorisBy($this->getUser()); $commentairesParMois = $commentaireRepository->countCommentairesParMois(); $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, ], ], ]); $chartDatesAjout = $chartBuilderInterface->createChart(Chart::TYPE_LINE); $ajoutsParMois = $filmRepository->countAjoutsParMois(); $months = []; $entryCounts = []; foreach ($ajoutsParMois as $data) { $months[] = $data['month']; $entryCounts[] = $data['entryCount']; } $chartDatesAjout->setData([ 'labels' => $months, 'datasets' => [ [ 'label' => 'Nombre de films ajoutés par mois', 'data' => $entryCounts ] ] ]); $chart->setOptions([ 'scales' => [ 'y' => [ 'suggestedMin' => 0, 'suggestedMax' => 100, ], ], ]); $months = []; $entryCounts = []; foreach ($commentairesParMois as $data) { $months[] = $data['month']; $entryCounts[] = $data['entryCount']; } $chartCommentairesAjout = $chartBuilderInterface->createChart(Chart::TYPE_LINE); $chartCommentairesAjout->setData([ 'labels' => $months, 'datasets' => [ [ 'label' => 'Nombre de films ajoutés par mois', 'data' => $entryCounts ] ] ]); $chart->setOptions([ 'scales' => [ 'y' => [ 'suggestedMin' => 0, 'suggestedMax' => 100, ], ], ]); return $this->render('dashboard/index.html.twig', [ 'chart' => $chart, 'chartAjoutsParMois' => $chartDatesAjout, 'chartCommentairesAjouts' => $chartCommentairesAjout ]); } }