SuperCube Process
Overview #
Cube process full classname is \koolreport\cube\processes\SuperCube
.
The SuperCube
is exactly Cube
with some added features. In SuperCube
process, you could specify multiple fields for rows
, multiple fields for columns
and multiple fields for each operators. For example:
<?php
use \koolreport\cube\processses\Cube;
class MyReport extends \koolreport\KoolReport
{
...
public function setup()
{
$this->src("sales")
->query("SELECT country,product,sale from tblPurchases")
->pipe(new SuperCube(array(
"rows" => "productCategory, productName",
"columns" => "orderYear, orderMonth",
"sum" => "dollar_sales, tax_amount",
"sum percent" => "dollar_sales, tax_amount",
"count" => "dollar_sales, order_id",
"count percent" => "dollar_sales, order_id",
"avg" => "dollar_sales",
)))
->pipe($this->dataStore("sales"));
}
}
The resulted table will look like this:
Product Category | Product Name | orderYear - 2014 | dollar_sales - sum | orderMonth - 12 | order_id - count | ... |
---|---|---|---|---|
Car | Citroen-15CV | 580,000 | 28 | ... |
Car | Ford Falcon | 730,000 | 45 | ... |
Truck | Ford F-150 | 480,000 | 32 | ... |
Summarized table format #
The summarized table of the SuperCube
process includes rows of distinct values of the "row"/"rows" fields (if defined) and columns whose names are in the format of "
Product Category | Product Name | orderYear - 2014 | dollar_sales - sum | orderYear - {{all}} | dollar_sales - sum | orderMonth - 12 | order_id - count | orderMonth - {{all}} | order_id - count | ... |
---|---|---|---|---|---|---|
Car | Citroen-15CV | 580,000 | 1,560,000 | 28 | 69 | ... |
Car | Ford Falcon | 730,000 | 1320,000 | 45 | 82 | ... |
Truck | Ford F-150 | 480,000 | 1730,000 | 32 | 98 | ... |
Get started with KoolReport
KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.