KoolReport's Forum

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

In pro version setValues true showing values without mouse over not working for Google columnchart #3058

Open Ankit Agarwal opened this topic on on May 25 - 5 comments

Ankit Agarwal commented on May 25

Pro version "setValues" => true not showing values without mouse over.

$columns = array(
                "category",
                "sale"=>array("label"=>"Sale","type"=>"number","prefix"=>"$",
                "setValues" => true),
                "cost"=>array("label"=>"Cost","type"=>"number","prefix"=>"$","setValues" => true),
                "profit"=>array("label"=>"Profit","type"=>"number","prefix"=>"$","setValues" => true),
            );
            
            ColumnChart::create(array(
                "dataSource"=>$category_amount,
                "columns"=>$columns,
                
                
            ));
KoolReport commented on May 25

May I know what you are trying to complete? It seems to me that the chart does not have property "setValues"

Ankit Agarwal commented on May 25

Please find the code, sql query and screenshot attached.

When we do a mouseover on the column we are able to see the values. But we need to see the values displayed even when there is no mouseover.

All the files on the link below

https://we.tl/t-FXJf8e4T1F

Sebastian Morales commented on May 25

For your purpose pls try chart column property "annotation":

\koolreport\widgets\google\ColumnChart::create(array(
    "title"=>"Sale Report",
    "dataSource"=>$this->dataStore('sale_amount'),
    "columns"=>array(
                "category",
                "sale"=>array(
                    "label"=>"Sale","type"=>"number","prefix"=>"$",
                    "annotation"=>function($row)
                    {
                        return "$".number_format($row["sale"]);
                    }
                ),
                ...
    )
)); 

https://www.koolreport.com/docs/google_charts/column_chart/#labeling-columns

You can even add multiple annotations with columns that have "role" => "annotation":

https://www.koolreport.com/examples/reports/google_charts/multi_annotation/

Ankit Agarwal commented on May 25

We used the below code you have given but getting error.

"annotation"=>function($row)

                {
                    return "$".number_format($row["sale"]);
                }

Copy of the code and the error on the below link

https://we.tl/t-x7N4uFZnvv

Sebastian Morales commented on May 26

I see that you applied serialize function on your chart's columns, which resulted in error when columns contains any function. There're two ways to solve this:

1 . Use other methods instead of serializing columns unless you must use serialize in any case.

2 . Try the following more complex solution:

//in setup file MyReport.php, copy the value columns like "sale", etc:
...
->pipe(new \koolreport\processes\CopyColumn(array(
    "sale2" => "sale",
    ...
)))
->pipe($this->dataStore('sale_amount'));

//in view file use those copied columns with "role" => "annotation"
\koolreport\widgets\google\ColumnChart::create(array(
    ...
    "dataSource"=>$this->dataStore('sale_amount'),
    "columns"=>array(
                "category",
                "sale"=>array(
                    "label"=>"Sale","type"=>"number","prefix"=>"$"
                ),
                "sale2"=>array("role" => "annotation", "type" => "string"),
                ...
    )
)); 

With this way there's no function in your chart's columns.

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

None