KoolReport's Forum

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

Chart not displayed #929

Open Sowmya opened this topic on on Jun 17, 2019 - 1 comments

Sowmya commented on Jun 17, 2019

Hi Koolreport Team, thank you so much for your support. I'm getting data grid, but data can't be displayed in chart format. I'm trying for this graphical images from last 2 weeks. Please Please Please Please .... help me out. Here I' attaching my code and output. I want graphical image. Please give me the guideline. I'm KoolReport Pro user...

SalesByCustomer.view.php

<?php 
    use \koolreport\widgets\koolphp\Table;
    use \koolreport\widgets\google\BarChart;
?>

<div class="text-center">
    <h1>Sales Report</h1>
    <h4>This report shows top 10 sales by customer</h4>
</div>
<hr/>

<?php
    BarChart::create(array(
        "dataStore"=>$this->dataStore('sales_by_customer'),
        "width"=>"100%",
        "height"=>"500px",
        "columns"=>array(
            "customerName"=>array(
                "label"=>"Customer"
            ),
            "dollar_sales"=>array(
                "type"=>"number",
                "label"=>"Amount",
                "prefix"=>"$",
            )
        ),
        "options"=>array(
            "title"=>"Sales By Customer"
        )
    ));
?>
<?php
Table::create(array(
    "dataStore"=>$this->dataStore('sales_by_customer'),
        "columns"=>array(
            "customerName"=>array(
                "label"=>"Customer"
            ),
            "dollar_sales"=>array(
                "type"=>"number",
                "label"=>"Amount",
                "prefix"=>"$",
            )
        ),
    "cssClass"=>array(
        "table"=>"table table-hover table-bordered"
    )
));
?>

SalesByCustomer.php

<?php
include APPPATH. "libraries\koolreport\core\autoload.php";
use \koolreport\processes\Group;
use \koolreport\processes\Sort;
use \koolreport\processes\Limit;

class SalesByCustomer extends \koolreport\KoolReport
{
    public function settings()
    {
        return array(
            "dataSources"=>array(
                "sales"=>array(
                    "connectionString"=>"sqlsrv:Server=localhost;Database=Demo",
                    "username"=>"sa",
                    "password"=>"sa1234",
                    "charset"=>"utf8"
                )
            )
        );
    }

    public function setup()
    {
        $this->src('sales')
        ->query("SELECT customerName,dollar_sales FROM Sales_by_Customer")
        ->pipe(new Group(array(
            "by"=>"customerName",
            "sum"=>"dollar_sales"
        )))
        ->pipe(new Sort(array(
            "dollar_sales"=>"desc"
        )))
        ->pipe(new Limit(array(10)))
        ->pipe($this->dataStore('sales_by_customer'));
    }
}

OUTPUT

Sales Report
This report shows top 10 sales by customer

Customer	Amount
Baane Mini Imports	$25,290
Vitachrome Inc.	$5,494

It gives me empty output.... Please help me, because here I'm the only PHP(Koolreport) developer in my organization, Please help me urgently. Today I have to finish this task....

KoolReport commented on Jun 17, 2019

If you open the browser console, does any error show?

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

CodeIgniter