Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
i get data not organized in my chartjs symfony

this is my function in my controller

   public function stat(ChartBuilderInterface $chartBuilder): Response
   {
   //livreur par nbr livraison
   $livreur = $this->getDoctrine()->getRepository(Livreur::class)->findAll();
   $livreurNom = [];
   $all=[];
   $numlivraisons=[];
   foreach($livreur as $l){
       $entityManager = $this->getDoctrine()->getManager();
       $query = $entityManager->createQuery(
           'SELECT c.nomlivreur ,COUNT(l) 
        FROM  App\Entity\Livraison l
         JOIN l.idLivreur c 
         WHERE l.idLivreur = :id'
       )
           ->setParameter('id', $l->getIdlivreur());

       $all[]=$query->getResult();

   }

   foreach($all as $l){
       $livreurNom[]=array_column($l, "nomlivreur");
       $numlivraisons[]=array_column($l, "1");
       $values[]=array_column($l, "nomlivreur","1") ;

   }

and this is my template

      var chart = document.getElementById("nbrlivparlivreur");
        let nbrlivparlivreur = new Chart(chart, {
            type: 'bar',
            data: {
                labels: {{l |  raw}},
                datasets: [{
                    label: "nombres de livraison",
                    backgroundColor: "#4e73df",
                    hoverBackgroundColor: "#2e59d9",
                    borderColor: "#4e73df",
                    data: {{num |  json_encode | raw}},
                }],
            },
        });

i get the data correctly from the database and organized but when i put it in the chart it become not organized as needed

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!