Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Sure you can, please use the ArrayDataSource like following;
class MyReport extends \koolreport\KoolReport
{
function settings()
{
return array(
"dataSources"=>array(
"apiarray"=>array(
"class"=>'\koolreport\datasources\ArrayDataSource',
"dataFormat"=>"associate",
)
)
)
}
function setup()
{
//Connect to your api here and load json, parse json string to array and
//store the data in the associate format like below:
// $data = array(
// array("customerName"=>"Johny Deep","dollar_sales"=>100),
// array("customerName"=>"Angelina Jolie","dollar_sales"=>200),
// array("customerName"=>"Brad Pitt","dollar_sales"=>200),
// array("customerName"=>"Nocole Kidman","dollar_sales"=>100),
// )
$this->src("apiarray")->load($data)
->pipe(...)
...
-.pipe($this->dataStore("result"));
}
}
For example you have a SaleByMonth report which is of course return total sale by month. You can make the api like this:
https://www.example.com/api/salereport?type=month
And then you can do:
if($_GET("type")=="month")
{
$report = new SaleByMonth;
$report->run();
echo $report->dataStore("result")->toJson();
}
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo