KoolReport's Forum

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

Conditionally format of the prefix in charts #269

Open Victor Garcia opened this topic on on May 5, 2018 - 5 comments

V
Victor Garcia commented on May 5, 2018

Hello team

I am developing a government application, which records agricultural and livestock production information.

In one of the reports, I use a bar chart that shows production by time period: for example, number of hectares of cotton and number of heads of cattle.

The issue is, I wonder if it is possible to display the correct prefix (hectares for agricultural activities, heads for livestock activities), bearing in mind that both can be differentiated by a 'type' column in the query.

I hope you have been able to understand me, and thank you very much!

K
KoolReport commented on May 6, 2018

Hi Victor,

I have sent you a new koolreport\widgets\google\Chart.php to your email. Please replace the old file and do as following:

BarChart::create(array(
    ...
    "columns"=>array(
        ...
        "stock"=>array(
            "formatValue"=>function($value,$row)
            {
                return $value." ".$row["type"];
            }
        )
    )
))

As you may guess, the "formatValue" receive function and in there you can format whatever you want. The function received $row in second parameter in which you can access to whole data row.

We have implemented "formatValue" in Table widget but have not done the same for Google Chart.

V
Victor Garcia commented on May 6, 2018

Works perfectly, thanks a lot

K
KoolReport commented on May 6, 2018

Thank you very much for your tips. Very appreciated!

J
James Schlies commented on Jun 17, 2022

I think I have a similar issue.

I have a situation where the individual cells contain a number, zero or 'NA'. If the cell is a number, we wish the format to be $99.99 but obviously when the value is NA - we do not want numeric formatting and we want the cell ignored regarding totaling. Can you point to an example?

Thanks, Jim

S
Sebastian Morales commented on Jun 20, 2022

Hi James, can you pls give a specific example with mock up screenshots if possible. Tks,

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

None