I have a set of data retrieved from MySQL and would like to pipe into the Pivot and extract the data set to a table.
In the Pivot Extract Sorting, I have specified the following option
"row" => array(
"parent" => array(
),
"sort" => array(
'confirm_amount - sum' => 'desc',
),
),
However, the table did not sort by confirm_amount. It just sorted by custname column.
`
use \koolreport\processes\ColumnMeta;
use \koolreport\pivot\processes\PivotExtract;
class CustomersYears extends koolreport\KoolReport {
function settings()
{
return array(
"dataSources"=>array(
"aimfs"=>array(
"connectionString"=>"xxx",
"username" =>"xx",
"password" =>"xxx",
"chartset"=>"utf8"
)
)
);
}
function setup()
{
$this->src('aimfs')
->query('select * from quote')
->pipe(new \koolreport\pivot\processes\PivotSQL([
"column" => "signed_month",
"row" => "custname",
"aggregates"=>array(
"sum"=>"confirm_amount",
"count"=>"confirm_amount"
),
]))
->pipe(new ColumnMeta(array(
"confirm_amount - sum"=>array(
'type' => 'number',
"prefix" => "$",
),
)))
->saveTo($node2);
$node2->pipe($this->dataStore('sales'));
$node2->pipe(new PivotExtract(array(
"row" => array(
"parent" => array(
),
"sort" => array(
'confirm_amount - sum' => 'desc',
),
),
"column" => array(
"parent" => array(
),
"sort" => array(
'signed_month' => function($a, $b) {
return (int)$a < (int)$b;
},
),
),
"measures"=>array(
"confirm_amount - sum",
"confirm_amount - count",
),
)))
->pipe($this->dataStore('pivotData'));
}
}
`
View file
use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\ColumnChart;
@session_start();
$CustomersYears = new CustomersYears;
$CustomersYears->run();
Table::create(array(
"dataStore"=>$CustomersYears->dataStore('pivotData'),
));