KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Cube /Table Now Data #1373

Closed Mike Carroll opened this topic on on Apr 2, 2020 - 2 comments

Mike Carroll commented on Apr 2, 2020

Hello,

I have a Cube that I am trying to creates based of an existing dataStore in a *.view.php script. The data store is working perfectly for an existing bar chart.

I am trying to use the data store to create a cube, but every time I try to use it in a table, I get no data.

Below is an example of the data in the data store

ShipperID       CountByMonth         OpenedDateYM    Name
A	                5	                        2020-03	            AName
B	                22	                        2020-03	            BName

Below is the code I am trying to use:

$node=$this->dataStore("ShipmentByCustomerByOpenedDateTop25")->pipe(new ColumnMeta(array(
            "CountByMonth"=>array(
                'type' => 'number',
                "prefix"=>"$",
            ),
        )));
     
        $node->pipe(new Cube(array(
            "row" => "ShipperID",
            "column" => "OpenedDateYM",
            "sum" => "CountByMonth",
        )))->pipe($this->dataStore('salesYearMonth'));

    
 		Table::create(array(
            "dataSource" => $this->dataStore("salesYearMonth"),
            "columns" => "OpenedDateYM",
        ));
Mike Carroll commented on Apr 2, 2020

Update,

If I include "$node=$this->dataStore("ShipmentByCustomerByOpenedDateTop25")->pipe(new ColumnMeta(array(" into the setup() function of the extends \koolreport\KoolReport php page it works.

I need to be able to do this with having the new Cube data being created/defined in the XXX.view.php page.

thanks,

KoolReport commented on Apr 3, 2020

The way you do is fine however it is better to keep dataStore the end point without further piping from it. Here is the pipeTree function that help you to branch the flow of data.

Example:

$this->src("data")
->pipe(new ColumnMeta(..))
->pipeTree(
    function ($node)
    {
        $node->pipe(new Filter(...))
        ->pipe($this->dataStore("store1"));
    },
    function ($node)
    {
        $node->pipe(new Filter(...))
        ->pipe($this->dataStore("store2"));
    }   
);

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None