KoolReport's Forum

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

Can not draw any google graphs, other than just the BarChart #1451

Closed Jorge opened this topic on on May 19, 2020 - 3 comments

Jorge commented on May 19, 2020

In the samples documentation, I have tried:

  1. "Sales by Quarter" sample which uses Google Column Chart class,
  2. "Sales by Country" sample which uses Google Pie Chart class and I am getting "Cannot read property 'isHtml' of null To use Koolreport library, I have the sentence: require_once "../../../koolreport/core/autoload.php"; Although the ..'widgets\koolphp\Table class is working fine. What am I doing wrong?

For instance, for the Sales by Quarter example, these are the scripts:

----------------------------------------------------------------
SalesByQuarter.php
----------------------------------------------------------------
// Require autoload.php from koolreport library
require_once "../../../koolreport/core/autoload.php";

//Specify some data processes that will be used to process
use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;
use \koolreport\processes\Sort;
//use \koolreport\processes\Limit;

//Define the class
class SalesByQuarter extends \koolreport\KoolReport
{
    use \koolreport\clients\Bootstrap;
    protected function settings()
    {
		// Define "sales" data source with mysql data base source
        return array(
            "dataSources"=>array(
                "sales"=>array(
                    "connectionString"=>"mysql:host=localhost;dbname=automaker",
                    "username"=>"root",
                    "password"=>"votive3102",
                    "charset"=>"utf8"
                ),
            )
        );     }
    public function setup()
    {
        $this->src('sales')
        ->query("
		SELECT
			orders.orderDate,
			sum(orderdetails.quantityOrdered * orderdetails.priceEach) as sales 
		FROM
			orders
		Inner Join orderdetails ON orderdetails.orderNumber = orders.orderNumber
		Group by orders.orderDate
		Order by orders.orderDate
		") 
        ->pipe(new TimeBucket(array(
			"orderDate"=>array(
            "bucket"=>"quarter"
			)
        )))
        ->pipe($this->dataStore('sales_by_quarter'));
    } 
}
----------------------------------------------------------------
SalesByQuarter.view.php
----------------------------------------------------------------
<?php
/*	SalesByQuarter.view.php
*/
	use \koolreport\widgets\google\ColumnChart;
    use \koolreport\widgets\koolphp\Table;

?>
<html>
    <head>
        <title>Quarter Sale Report</title>
    </head>
    <body>
        <?php 
        ColumnChart::create(array(
            "dataStore"=>$this->dataStore("sales_by_quarter")
        ));
        ?>
    </body>
</html>
KoolReport commented on May 19, 2020

There could be nothing wrong with your code, just that Google Chart has just updated so it causes this issue. We have released KoolReport 4.7.1, could you please download the library again, the new version contains the fix for it.

Reference: Google Charts is required to update

KoolReport commented on May 19, 2020

Or another solution, you add dummy property to options like below

        <?php 
        ColumnChart::create(array(
            "dataStore"=>$this->dataStore("sales_by_quarter"),
            "options"=>array(
                "fixTheChart"=>true
            )
        ));
        ?>

it will work

Jorge commented on May 19, 2020

Thank you, upgrading to version 4.7.1 worked fine.

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
solved

None