src/Controller/DefaultController.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Service\CommonService;
  7. use App\Service\DefaultService;
  8. class DefaultController extends AbstractController
  9. {
  10.     function __construct(CommonService $commonServiceDefaultService $defaultService) {
  11.         $custInfo $commonService->custInfo();
  12.         $this->counts $custInfo['counts'];
  13.         $this->userinfo $custInfo['info'];
  14.     }
  15.     /**
  16.      * @Route("/", name="default")
  17.      */
  18.     public function index(): Response
  19.     {
  20.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  21.         return $this->render('default/index.html.twig', [
  22.             'controller_name' => 'HomePage',
  23.             'user' => $this->userinfo,
  24.             'counts' => $this->counts,
  25.             'areas' => $this->buildAreas(),
  26.             'pies' => $this->buildPies()
  27.         ]);
  28.     }
  29.     private function buildPies() {
  30.         $space 'myPieChart1';
  31.         $labels = array('Blue''Red''Yellow''Green');
  32.         $data = array(12.2115.5811.258.32);
  33.         $colors = array('#007bff''#dc3545''#ffc107''#28a745');
  34.         $charts[] = array('space' => $space'labels' => $labels'data' => $data'colors' => $colors);
  35.         $space 'myPieChart2';
  36.         $labels = array('Orange''Yellow''Green''Blue');
  37.         $data = array(21.2151.581.258.32);
  38.         $colors = array('#dc3545''#ffc107''#007bff''#28a745');
  39.         $charts[] = array('space' => $space'labels' => $labels'data' => $data'colors' => $colors);
  40.         $space 'myPieChart3';
  41.         $labels = array('Yellow''Red''Green''Blue');
  42.         $data = array(51.5831.21,  19.2514.32);
  43.         $colors = array('#ffc107''#dc3545''#007bff''#28a745');
  44.         $charts[] = array('space' => $space'labels' => $labels'data' => $data'colors' => $colors);
  45.         return $charts;
  46.     }
  47.     private function buildAreas() {
  48.         
  49.         $space 'myAreaChart1';
  50.         $labels = array('Mar 1''Mar 2''Mar 3''Mar 4''Mar 5''Mar 6''Mar 7''Mar 8''Mar 9''Mar 10''Mar 11''Mar 12''Mar 13');
  51.         $data = array(10000301622626318394182872868231274332592584924159326513198438451);
  52.         //$colors = array('#007bff', '#dc3545', '#ffc107', '#28a745');
  53.         $charts[] = array('space' => $space'labels' => $labels'data' => $data);
  54.         return $charts;
  55.     }
  56. }