Hi,
I am trying to add data transformation processes dynamically into the pipeline using the ProcessGroup method. This is not working so far. My question is if this is possible at all and if so how to do it.
This is some test code I wrote to see if it is possible.
ProcessGroup
<?php
use \koolreport\processes\Filter;
class MyProcessGroup extends \koolreport\core\ProcessGroup
{
public function setup()
{
$processes = [];
$filter1 = new Filter(array(
array(
"value", ">", 50000
)
));
$filter2 = new Filter(array(array(
"time", "=", "2018"
)));
$processes[] = $filter1;
$processes[] = $filter2;
$incoming = $this->incoming();
foreach ($processes as $process) {
$incoming->pipe($process);
}
$incoming->pipe($this->outcoming());
}
}
The report itself
<?php
require_once "../vendor/koolreport/core/autoload.php";
class PopulationInTheNetherlands extends \koolreport\KoolReport
{
protected function settings()
{
return array(
"dataSources" => array(
"gdp" => array(
"class" => '\koolreport\datasources\CSVDataSource',
"filePath" => "C:\Users\Koen\Downloads\gdp.csv"
)
)
);
}
protected function setup()
{
$processGroup = new MyProcessGroup();
$this->src('gdp')
->pipe($processGroup)
->pipe($this->dataStore('data'));
}
}
In the view I just simply display the data as a table for debugging purposes.
<?php
use \koolreport\widgets\google\Table;
?>
<div class="report-content">
<div class="text-center">
<h1>GDP Per Year</h1>
</div>
</div>
<div style="width: 800px; height: 300px;">
<?php
Table::create(array(
"dataSource" => $this->dataStore('data')
))
?>
</div>