KoolReport's Forum

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

Single page - can't display google charts #351

Open Anita opened this topic on on Jul 5, 2018 - 3 comments

Anita commented on Jul 5, 2018

Dear support,

I have been working on a single page. Displaying a koolphp table works well, but I can' t display google charts. When displaying the result in the browser, there is a space reserved for the chart, but nothing appears. I can't figure out what is wrong. Can you help, please ? Thanks a lot. Here's my code :

<?php
//Index.php
require_once "../koolreport/autoload.php";
use \koolreport\widgets\koolphp\Table; //when creating a table, all works fine
use \koolreport\widgets\google\BarChart;//doesn't work


class Single_page extends \koolreport\KoolReport
{
    use \koolreport\instant\SinglePage;
    use \koolreport\clients\Bootstrap;

    function settings()
    {
        include "parametres_connexion_database.php";
        return  $database_connection;
    }

      function setup()
    {
        $this->src('myDatabase') ->query('SELECT * from main_request where "Team" = \'team\'')
    	
        ->pipe($this->dataStore("team1"));
        
    }
}

$report = new Single_page;
$report->start();
?>
<html>
    <head>
        <title>Bar chart single page</title>
    </head>
    <body>
        <h1>Results</h1>
        <?php
        
              BarChart::create(array(
                "dataStore"=>$report->dataStore("team1"),
                 "columns"=>array("User id", "numberRequests"),
            ));
        ?>
    </body>
</html>
<?php $report->end(); ?>
KoolReport commented on Jul 5, 2018

Hi Anita, Could you please let me know the location of "koolreport" folder. Is "koolreport" folder accessible by browser. Your code seems good but because the resource of chart (js file) could not load that why's the charts is blank. Please describe your folder structure.

Anita commented on Jul 5, 2018

Hi Support,

Here's the print screen.

OMAR GONSENHEIM commented on Feb 21, 2019

Had a similar problem and discovered that the "instant" classes have to be required manually. Koolreport autoload DOES NOT load the instant classes. Add these 3 lines right after require_once "../koolreport/autoload.php";

../ require_once "instant/SinglePage.php";

../require_once "instant/Widget.php";

../require_once "instant/TempReport.php";

Also noted that the only way to instantiate a widget in a single page is using the Widget base class wrap because it creates a temporary view to actually render the widget.

I tried to create a widget in a single page, making a call BarChart::create() just like you did and how it is shown in the "Instant" documentation and charts would not display.

Instead of:

BarChart::create(array(

            "dataStore"=>$report->dataStore("team1"),
             "columns"=>array("User id", "numberRequests"),));

try:

Widget::create(BarChart::class,array(

            "dataStore"=>$report->dataStore("team1"),
             "columns"=>array("User id", "numberRequests"),));

Hope it helps

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