KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Confuse why my pie chart show blank data / other #3025

Open ahmad irfan opened this topic on on Apr 3, 2023 - 3 comments

ahmad irfan commented on Apr 3, 2023

hello and very good morning, I'm trying to show data on pie chart but the data is not plotted/shown on the pie chart, instead it become grey pie chart. This is my first time using koolreport. My data is supposed to be collected from mysql where i need to combine two table. Table 1, i used reference number, and description while Table 2, I used status name. This two table are link through status id since status_id is a foreign key for table 1

ahmad irfan commented on Apr 3, 2023
  1. index.view.php
 <div class="container">

        <h1 class="text-center mt-5">B5 Firs</h1>

        <?php

        use koolreport\widgets\google\DonutChart;
       


        DonutChart::create(array(
            "dataSource"=>$this->dataStore("total"),

            // "columns"=>array("statuses.name", "process_name")
        ));
        ?>
        <?php
        use koolreport\widgets\koolphp\Table;


        Table::create(array(
            "title"=>"Bilangan kes mengikut negeri",
            "dataSource"=>$this->dataStore("result"),
            "paging"=>array(
                "pageSize"=>7,
                "pageIndex"=>0,
                "align"=>"center"
        )));
        ?>
</div>
ahmad irfan commented on Apr 3, 2023

index.php

<?php

namespace App\Reports;

// require_once dirname(__FILE__)."/../../vendor/koolreport/autoload.php"; // No need, if you install KoolReport through composer

class report1 extends \koolreport\KoolReport

{
    use \koolreport\laravel\Friendship;
    use \koolreport\clients\Bootstrap;

    protected function settings()
    {
        return array(
            "dataSources"=>array(
                "ejinayat_v4"=>array(
                    "connectionString"=>"mysql:host=localhost;dbname=ejinayat_v4",
                    "username"=>"root",
                    "password"=>"",
                    "charset"=>"utf8"
                )
            )
        );
    }

    // By adding above statement, you have claim the friendship between two frameworks
    // As a result, this report will be able to accessed all databases of Laravel
    // There are no need to define the settings() function anymore
    // while you can do so if you have other datasources rather than those
    // defined in Laravel.

    //Setup report
    protected function setup(){
        $this->src("ejinayat_v4")
        ->query("
        SELECT reference_number,description,status_id,process_id FROM b5_firs
        ORDER BY status_id")
        // ->params(array(":status_id"<="1"))
        ->pipe($this->dataStore("result"));

        $this->src("ejinayat_v4")
        ->query("
            SELECT b5_firs.reference_number, b5_firs.process_id, statuses.name FROM statuses 
            JOIN statuses ON b5_firs.status_id = statuses.id
      
           
        ")
        ->pipe($this->dataStore("total"));

    }
   
}
KoolReport commented on Apr 3, 2023

In the DonutChart, please use columns to specify the needed columns. The DonutChart will need 2 columns, first column is string type containing name of category, the second column is a number specifying the quantity.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None