KoolReport's Forum

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

TimeBucket: How to get as bucket column value - the name of the days #674

Closed Eugene opened this topic on on Feb 13, 2019 - 7 comments

Eugene commented on Feb 13, 2019

Hi, I would like to have the name of the days in the aggregated column

I try this but without success

$node->pipe(new TimeBucket(array(
            "date" => "dayofweek",
            "formatString"=>"l",
        )))
KoolReport commented on Feb 13, 2019

You do:

$node->pipe(new TimeBucket(array(
            "date" =>array(
                "formatString"=>"l"
            )
)))
Eugene commented on Feb 14, 2019

Thanks

Eugene commented on Feb 14, 2019

but how to sort it now starting from Monday

KoolReport commented on Feb 14, 2019

You do this:

->pipe(TimeBucket::process(array(
    "date"=>array(
        "formatString"=>"N"
    )
)))
->pipe(Sort::process(array(
    "date"=>"asc"
)))
->pipe(Custom::process(function($row){
    $map = ["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
    $row["date"] = $map[$row["date"]];
    return $row;
}))
Eugene commented on Feb 14, 2019

Thanks, it is clear... but looks a bit complicated I think the sort process should know how to sort some usual string value - names of the day and months... maybe something else

KoolReport commented on Feb 14, 2019

Normally we do not convert to day name/month name in process phases, we keep it as number so that we can sort and do conversion at the end in Widget (using formatValue properties of Table). It is rather hard to force the Sort process to sort those strings as it varies from language to language. and also Sort may confuse developer if his intention is to sort by alphabeta.

Eugene commented on Feb 14, 2019

Ah I see... I did not think that it is better to do in Widget... You are right. :-)

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
solved

None