KoolReport's Forum

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

Google Line Chart vAxis call function #2302

Closed Clemens Reinhold opened this topic on on Aug 25, 2021 - 2 comments

Clemens Reinhold commented on Aug 25, 2021

Hey =)

I want to do something like this:

                    "vAxis" =>array(
                        "direction" => function($row) {
                            if ($row['timeBased'] == true) {
                                return -1;
                            }
                            else {
                                return 1;
                            }
                        },
                    ),

If the row 'timeBased' is true, then the values of vAxis should be reverted.

Original:

Revert:

There are multiple Charts like this in a report. Some are timeBased and others are not.

Atm it just work like this:

"vAxis" =>array(
     "direction" => "-1",
),

or:

"vAxis" =>array(
     "direction" => "1",
),

Thank you =)

Sebastian Morales commented on Aug 26, 2021

Clemens, Google chart's direction only takes 1 or -1 value, not a function. Thus, you would have to calculate your variable $isTimeline based on your datastore's data and apply it to direction like this:

$row0 = $this->dataStore("myDS")->data()[0];
$isTimeline = $row0['timeBased'];

LineChart::create(array(
    ...
    "vAxis" =>array(
         "direction" => $isTimeline ? -1 : 1,
    ),    
Clemens Reinhold commented on Aug 26, 2021

Thank you, it´s working perfect.

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