KoolReport's Forum

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

Creating a ProgressCard. Where is the array? #1551

Closed Richb201 opened this topic on on Aug 2, 2020 - 6 comments

Richb201 commented on Aug 2, 2020

The code below (most of which is from the example) is showing a percent complete of zero. I can see that the num_titles=5 and the num_title_complete=3 in the dataStore with my debugger. Where is the array that is created? I'd like to check the values in it? When I hardcode 5 and 3 into value and baseValue, it works fine.

    \koolreport\amazing\ProgressCard::create(array(
        "title"=>"Percent Complete",
        "infoText"=>"Three Way Risk Analysis",
        "value"=>$this->dataStores['global_summary']['rows'][0]['num_titles_complete'],   //completed rows
        "preset"=>"primary",
        "baseValue"=>$this->dataStores['global_summary']['rows'][0]['num_titles'],  //number of rows
        "format"=>array(
            "value"=>array(
                "prefix"=>"complete"
            ),
            "indicator"=>array(
                "decimals"=>2
            )
        ),
        "cssClass"=>array(
            "icon"=>"fa fa-euro"
        ),
    ));

I also tried using a SimpleCard like this:

    SimpleCard::create(array(
        "title"=>"Number of Employees",
        "value"=>$this->dataStores['campaigns2']['rows'][0]['number_of_employees'],
        "preset"=>"primary",
        "cssClass"=>array(
            "icon"=>"fa fa-shopping-cart",
            "card"=>"p-3",
        ),
    ));

But again, the value is not working correctly for me.

KoolReport commented on Aug 3, 2020

Let try this if it works:

"value"=>$this->dataStore("campaigns2")->get(0,"number_of_employees")
Richb201 commented on Aug 3, 2020

That worked. Thx. Here is what I see

Now I was hoping to see 3/5 or .6 or 60% complete. I can get rid of the word complete but I don't know why the 5 is showing up.

KoolReport commented on Aug 3, 2020

May you post your code?

Richb201 commented on Aug 3, 2020
          <?php
        \koolreport\amazing\ProgressCard::create(array(
            "title"=>"Percent Complete",
            "infoText"=>"Three Way Risk Analysis",
            "value"=>$this->dataStore("global_summary")->get(0,"num_titles_complete"),

            "preset"=>"primary",
            "baseValue"=>$this->dataStore("global_summary")->get(0,"num_titles"),  //number of rows

            "format"=>array(
                "value"=>array(
                    "prefix"=>""
                ),
                "indicator"=>array(
                    "decimals"=>2
                )
            ),
            "cssClass"=>array(
                "icon"=>"fa fa-euro"
            ),
        ));
        ?>
KoolReport commented on Aug 3, 2020

The percentage is calculated by formular $value / $baseValue so I guess you should switch values of them. It should be "num_titles_complete" for "value" and "num_titles" for "baseValue".

Richb201 commented on Aug 3, 2020

I think that "value" is the number that is displayed. Better documentation would really help.

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