Hello guys i am trying to pass an array to a js file but i have this error :
An exception has been thrown during the rendering of a template ("Notice: Array to string conversion").
Soo this what i want : data: ['2017/7','2017/8']
so i do it like this (in twig) : data: '{{ user_month_month }}'
And when i vardump user_month_month this is what i get :
array(2) { [0]=> string(6) "2018-7" [1]=> string(6) "2018-8" }
So i think that i don't call it well in the js part, what should i do ?
if you want there is my controller :
public function GraphicShow()
{
$em = $this->getDoctrine()->getManager();
$users = $em->getRepository('AppBundle:User')->countUsers();
$not_logged = $em->getRepository('AppBundle:User')->countNotActiveUsers();
$logged = $em->getRepository('AppBundle:User')->countActiveUsers();
$user_month_months = $em->getRepository('AppBundle:Profile')->countByMonthMonth();
$user_month_totals = $em->getRepository('AppBundle:Profile')->countByMonthTotal();
$array_totals = array();
$array_months = array();
foreach($user_month_totals as $user_month_total) {
$array_totals[] = intval($user_month_total["total"]);
}
foreach ($user_month_months as $user_month_month) {
$array_months[] = $user_month_month["month"];
}
$not_logged_result = $not_logged["number"] / $users["number"] * 100;
$logged_result = $logged["number"] / $users["number"] * 100;
var_dump($array_months);
die();
return $this->render('admin/user/pie_stats.html.twig', array(
'user_month_month' => $array_months,
'user_month_total' => $array_totals,
'user_not_logged' => $not_logged_result,
'user_logged' => $logged_result,
'users' => $users,
'loggedAs' => $this->getUser(),
'alert' => 0,
));
}
ps / edit : the date is for a graphic and it looks like this :
Hope that i explain well, thx for all who will try to answer :p
With DarkBee method i got this :

