KoolReport's Forum

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

Adding empty rows #143

Open Nicolas Chapleau opened this topic on on Nov 1, 2017 - 3 comments

Nicolas Chapleau commented on Nov 1, 2017

I am trying to see what is the best way of adding empty rows to a data source.

Current

Name    Time    Calls
----    ----    -----

N1      1:00    2
N1      2:00    4
N1      5:00    10

Want

Name    Time    Calls
----    ----    -----

N1      1:00    2
N1      2:00    4
N1      3:00    0
N1      4:00    0
N1      5:00    10
...

I am using timeBucket which does a great job with existing data, but not sure how to proceed on adding the missing values. It would be nice to have timeBucket with an option to fill in the blanks, but in the meantime, do you have other suggestions?

Nicolas Chapleau commented on Nov 1, 2017

Before you respond I will try the technique in ticket #74...

KoolReport commented on Nov 1, 2017

Hi Nicolas,

Here is advanced solution: Create your own process


class MyReport extends \koolreport\KoolReport
{
    ...
    function setup()
    {
        ...
        ->pipe(new MyProcess())
        ...
    }
}

class MyProcess extends \koolreport\core\Process
{
    function onInput($row)
    {
        // Here is where the MyProcess receives data row by row.
        // You can pipe data from here to next process by next() function
        $this->next($row);
    }
}

In the onInput() function, each time you call $this->next(), a row of data will be sent to the next process. So basically you can do whatever you want here with data. For example, you save the previous row and later check if the time of current row has step difference from the time of previous row. if the time of previous row is "2:00" but the current row is "5:00", you need to use next() function to send 2 fake rows with time = "3:00" and "4:00" before sending real row of time ="5:00".

Please let me know if you need further assistance.

Nicolas Chapleau commented on Nov 2, 2017

Thanks, that's exactly what I was looking for, thanks for the tip.

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
wiki
help needed

None