KoolReport's Forum

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

Category showRawValue, helper and tooltip #2799

Open GHSix opened this topic on on Aug 19, 2022 - 7 comments

GHSix commented on Aug 19, 2022

The Category metric class has 2 options that seems to be doing nothing. I'm using it wrong?

use \koolreport\dashboard\metrics\Category;
use \koolreport\dashboard\fields\Text;

class ProductTopNCM extends Category
{
    protected function onInit()
    {
        $this->title('Top 5 Products')
            ->helper('Need help!!!') // <-- Does nothing here and gives error if added to any field
            ->type('success')
            ->width(1/3)
            ->lazyLoading(true);
    }
    
    protected function dataSource()
    {
        return $this->dashboard()->getTpNcm();
    }

    protected function fields()
    {
        return [
            $this->group(Text::create('ncm'))
                ->showTop(5)
                ->andShowOthers(),
            $this->count(Text::create('ncm'))
                ->showRawValue(true) // <-- True or False, the value is still shown as percentage
        ];
    }
}

But, besides show the raw value of the fields, I too would like to be able to "format" the content of chart mouseover tooltip, so I can add the details info of each category, that in my case, are too large sentences to be used diretcly on the category field. Is that possible?

KoolReport commented on Aug 20, 2022

For the showRawValue, you do this:

$this->count(Text::create('ncm'))
                ->showRawValue(true)
                ->suffix("")

For other issue, I will consult dev.team.

GHSix commented on Aug 21, 2022

The showRawValue to need suffix to work, seems a bug in the code or in the docs, someone is lacking something.

Anyway, I tried to use the suffix idea to show something but didn't know how to reach the row value. Can I refer to another column in the same row?

ie (something like):

$this->count(Text::create('ncm'))
                ->showRawValue(true)
                ->suffix(' - '. $this->row['ncm_descr']->value()) // $this here does not have "row"
KoolReport commented on Aug 22, 2022

Hi GHSix,

When aggregation is performed, except for field like category or measure, other field may not be available anymore. Does the count overthere has a fixed unit like "hours" or "units", you may put to suffix there?

GHSix commented on Aug 22, 2022

If I can't reach the other columns to get their values, them use either suffix or graph tooltip is useless in this case.

What I'm counting there is the just the quantitie of a "product category number", if I could add this "category number" description somewhere, like an extended legend, it would be of great help for users but, if I can't reach other columns, I guess it can't be done.

KoolReport commented on Aug 22, 2022

I believe there will be solution, let me consult dev.team then I will answer you. Thank you for your patience.

GHSix commented on Oct 25, 2022

I'm having 2 difficulties with Category.

1- When formating the Number field it will show right in the list but not in the total above.

2- When applying Filter, the graph is going crazy.

Here we can see 1 and 2 happening:

Code:

class ProductTopNCM extends Category
{
    protected function onInit()
    {
        $this->title(Lang::t('Top 5 NCM Cat.'))
            ->type('success')
            ->width(1/3)
            ->lazyLoading(true);
    }
    
    protected function dataSource()
    {
        return $this->dashboard()->getDataG1()
            ->run()
            ->process(\koolreport\processes\Filter::process([
                ['ncm', '!=', '.0']
            ]));
    }

    protected function fields()
    {
        return [
            $this->group(Text::create('ncm'))->showTop(5)->andShowOthers(),
            $this->sum(Number::create('qtd_ncm'))->showRawValue(true)->suffix('')->decimals(0)->decimalPoint(Lang::t('.'))->thousandSeparator(Lang::t(',')),
        ];
    }
}
GHSix commented on Nov 10, 2022

Am I using it wrong?

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

Dashboard