Introduce Instant Package
November 10, 2017In today tutorial, I would like to introduce a free and very helpful package called Instant
. As you may know that KoolReport contains many useful widgets such as KoolPHP Table or Google Charts. However, the widgets can only be used within the KoolReport environment. As a result, in order to use those widgets, you need to setup a report and include those widgets in the report's view. This is troublesome and not convenient.
The Instant
package will solve above problem. It let you use the Widgets instantly inside your application without creating a covering report. As a result, if you have data and would like to visualize them instantly, it become very easy.
Get started
Suppose you have below array data:
$data = array(
array("country"=>"US","amount"=>50000),
array("country"=>"Canada","amount"=>31000),
array("country"=>"Mexico","amount"=>42000),
)
Those data could be from you database or you calculate from somewhere and you would like to visualize them in a PieChart
, you can do as follow:
Step 1: Register the library at top of your PHP page
<?php
require_once "../koolreport/core/autoload.php";
use \koolreport\instant\Widget;
use \koolreport\widgets\google\PieChart;
?>
Step 2: Start creating PieChart
anywhere with following code:
<?php
Widget::create(PieChart::class,array(
"data"=>$data
));
?>
It is done! Easy isn't it?
The same manner can be applied to KoolPHP Tables and other types of widgets. Now you have turned KoolReport into a powerful Charts and Graphs library that you can use instantly in your web application.
If you have any question, you may reply to us of this email.
See you in the next tutorial.
Resources
<3 koolreport team