Sparkines

This example shows how to use Sparklines charts in your report.

Chart Type Demo
Bar
Line
Box Plot
Pie
Tristate
Bullet

We would like to introduce Sparklines package in this example. This package contains tiny charts which you can use in your report to show trend to get the feel or overview of data

<?php
require_once "MyReport.php";

$report = new MyReport;
$report->run()->render();
<?php
//Step 1: Load KoolReport
require_once "../../../../koolreport/autoload.php";

//Step 2: Creating Report class
class MyReport extends \koolreport\KoolReport
{
    protected function settings()
    {
        return array(
            "dataSources"=>array(
                "stock"=>array(
                    "class"=>'\koolreport\datasources\CSVDataSource',
                    'filePath'=>dirname(__FILE__)."/stock.csv",
                )
            )
        );
    }
    protected function setup()
    {
        $this->src("stock")
        ->pipe($this->dataStore("stock"));
    }
}
<?php
    use \koolreport\sparklines\Bar;
    use \koolreport\sparklines\Box;
    use \koolreport\sparklines\Bullet;
    use \koolreport\sparklines\Line;
    use \koolreport\sparklines\Pie;
    use \koolreport\sparklines\Tristate;
?>
<div class="report-content">
    <div class="text-center">
        <h1>Sparkines</h1>
        <p class="lead">
            This example shows how to use Sparklines charts in your report.
        </p>
    </div>

    <div class="row">
        <div class="col-md-8 col-md-offset-2 offset-md-2">
            <table class="table table-striped table-bordered">
                <thead>
                    <tr>
                        <th>Chart Type</th>
                        <th style="text-align:center">Demo</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Bar</td>
                        <td style="text-align:center">
                        <?php
                        Bar::create(array(
                            "dataSource"=>$this->dataStore("stock"),
                            "column"=>"volume",
                        ));
                        ?>
                        </td>
                    </tr>
                    <tr>
                        <td>Line</td>
                        <td style="text-align:center">
                        <?php
                        Line::create(array(
                            "dataSource"=>$this->dataStore("stock"),
                            "column"=>"price",
                        ));
                        ?>
                        </td>
                    </tr>
                    <tr>
                        <td>Box Plot</td>
                        <td style="text-align:center">
                        <?php
                        Box::create(array(
                            "dataSource"=>$this->dataStore("stock"),
                            "column"=>"price",
                        ));
                        ?>                        
                        </td>
                    </tr>
                    <tr>
                        <td>Pie</td>
                        <td style="text-align:center">
                        <?php
                        Pie::create(array(
                            "dataSource"=>$this->dataStore("stock")->take(5),
                            "column"=>"volume",
                        ));
                        ?>                        
                        </td>
                    </tr>

                    <tr>
                        <td>Tristate</td>
                        <td style="text-align:center">
                        <?php
                        Tristate::create(array(
                            "data"=>array(1,1,0,1,-1,-1,1,-1,0,0,1,1),
                        ));
                        ?>  
                        </td>
                    </tr>
                    <tr>
                        <td>Bullet</td>
                        <td style="text-align:center">
                        <?php
                        Bullet::create(array(
                            "dataSource"=>$this->dataStore("stock")->take(10),
                            "column"=>"volume",
                        ));
                        ?>  
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>

</div>
datepricevolume
2018-07-01 20 54
2018-07-02 22 60
2018-07-03 23 67
2018-07-04 24 53
2018-07-05 23 55
2018-07-06 25 22
2018-07-07 26 44
2018-07-08 24 33
2018-07-09 21 42
2018-07-10 25 66

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport