Home forums Using CanvasJS PHP Foreach loop the dataPoints for Chart

This topic contains 1 reply, has 2 voices, and was last updated by  Shashi Ranjan 6 months, 4 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #24746

    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,

    
    <?php
    foreach($users as $user):
    $dataPoints = array(
        array("label"=> $user->username, "y"=> 590),
    
    );
    endforeach;
    ?>
    <script>

    However, it is just returning one Username.

    #24762

    @mhiggins,

    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?


    Shashi Ranjan
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.