Home › forums › Using CanvasJS › PHP Foreach loop the dataPoints for Chart
Tagged: array, Codeigniter, Foreach, php, PieChart
Hey, I want to Display a Pie Chart on my Website. The Pie Chart will show the amount of tasks each user has completed from the DB.
This will change over time, and the amount of users will likely increase as will the amount of tasks each user has completed.
So I am trying the following,
foreach($users as $user):
$dataPoints = array(
array("label"=> $user->username, "y"=> 590),
However, it is just returning one Username.
Ideally, the code shared above should loop through the variable $users length. As we don’t know the exact length of the $users can you please share a sample project reproducing the issue over Google Drive/One Drive so that we can look into the code, understand it better and help you out?
You must be logged in to reply to this topic.