KoolReport's Forum

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

Additional attributes for Pivot package #71

Open bysystem opened this topic on on Aug 10, 2017 - 11 comments

bysystem commented on Aug 10, 2017

Dear support team,

I'm impressed about the easy use of koolreport and the great support from your side!

I have purchased all the packages, also Pivot as well.

I could create / modify the sample pivot example and it looks as follows:

My setup:

<?php require_once "../koolreport/autoload.php"; use \koolreport\processes\Filter; use \koolreport\processes\ColumnMeta; use \koolreport\pivot\processes\Pivot; use \koolreport\processes\Group; use \koolreport\processes\Sort; use \koolreport\processes\Limit;

class autoreppivot extends koolreport\KoolReport {

function settings()
{

...

}

function setup() {

$node = $this->src('sales')
->query("SELECT Geschaeftsjahr, Monat, WerbegruppeVerbund, NikonKdName, Verkaufsmenge, Umsatz FROM Reporting.autorep_v_noNulls")
->pipe(new Pivot(array(
  "dimensions" => array(
    "column" => "Geschaeftsjahr, Monat",
    "row" => "WerbegruppeVerbund, NikonKdName"
  ),
  "aggregates"=>array(
    "sum" => "Umsatz",
    "count" => "Verkaufsmenge"
  )
)))
->pipe($this->dataStore('Reporting.autorep_v_noNulls'));  

} }

And my *.view.php:

<?php use \koolreport\pivot\widgets\PivotTable; ?>

Nikon AutoRep-Pivot

Umsätze nach Werbegruppe-Ort-Kundenname


<?php PivotTable::create(array( "dataStore"=>$this->dataStore('Reporting.autorep_v_noNulls'), /* 'measures'=>array(

'Pivot-Column-Title'

),

'rowCollapseLevels' => array(1), 'columnCollapseLevels' => array(0, 1, 2), */ 'totalName' => 'GESAMT'

)); ?>

Now my issue: - When I deactivate the PivotTable attributes code lines for measures, rowCollapseLevels, coulumnCollapseLevels then I can retrieve the values sum / count as defined in the controller (see screenshot please) - BUT: When I activate these lines --> no results!!

Are there any syntax errors?

Kind regards, bysystem

David Winterburn commented on Aug 11, 2017

Hi bysystem,

Please change your measures property like this:

'measures' => array(
  "Umsatz - sum", 
  'Verkaufsmenge - count',
),

In the PivotTable view, a measure is of the syntax "{dataField1} - {aggregate}" which is computed from the Pivot process' setting:

'aggregates'=>array(
  '{aggregate}' => '{dataField1}, {dataField2}, ...'
)

Please let us know if this solves the problem for you. Thanks!

David Winterburn commented on Aug 11, 2017

I forgot another point. In case you want to change the measures' display title in the table, please use use this property:

'headerMap' => array(
  'Umsatz - sum' => 'Sum of Umsatz',
  'Verkaufsmenge - count' => 'Number of Verkaufsmenge',
),
bysystem commented on Aug 11, 2017

Dear David,

thx a lot for your response. That moves me on! Measures are now OK. Aggregates are now fine. HeaderMap is implemented. But 2 thinks won't work!

I changed my setup() as follows:

function setup() {

$node = $this->src('sales')
->query("SELECT Geschaeftsjahr, Monat, WerbegruppeVerbund, NikonKdName, Verkaufsmenge, Umsatz FROM Reporting.autorep_v_noNulls")
->pipe(new Pivot(array(
  "dimensions" => array(
    "column" => "Geschaeftsjahr, Monat",
    "row" => "WerbegruppeVerbund, NikonKdName"
  ),
  "measures" => array(
    "Umsatz - sum",
    "Verkaufsmenge - sum",
  ),
  "aggregates" => array(
    "sum" => "Umsatz, Verkaufsmenge",
  )
)))

and my view.php as follows:

PivotTable::create(array( "dataStore"=>$this->dataStore('Reporting.autorep_v_noNulls'),

"rowCollapseLevels" => array(1,2), "columnCollapseLevels" => array(0,1,2),

"headerMap" => array(

"Umsatz - sum" => "&sum; Umsatz",
"Verkaufsmenge - sum" => "&sum; Verkaufsmenge"

),

"totalName" => 'GESAMT'

));

As you can see in the screenshot below I need to fix the following points:

  1. The second dimension column "Monat" is not appearing in the row under "Geschaefsjahr" 154ki
  2. Collapsing with "+" icon is not working (probably I could not understand the CollapseLevels array hirarchy!?)

David Winterburn commented on Aug 11, 2017

Hi bysystem,

Please move the property "measures" from the Pivot process' setup to the PivotTable widget's create function. In case you don't set a "measures" property for the PivotTable widget, it will automatically use all the aggregates set up by Pivot process.

The row and columnCollapseLevels are for initial loading, the pivot table will automatically collapse the rows and columns to make it compact for viewer. After loading, viewers could expand/collapse the row and column levels by clicking plus/minus icon.

Is it possible for you to send us an online link to your webpage so we could check what went wrong? If not, please open your page in Chrome or Firefox, press F12 to open developer tool and let us know if there's any javascript error (red messages) so we could fix it for you. Thanks!

bysystem commented on Aug 11, 2017

Hi David,

thx for explanation. I understand the common funtion of collapse on a webpage but it was not clear for me to understand the arrays! However I followed you advice and put the measures propertiy into the PivotTable widget:

But still when I activate the code lines for "rowCollapseLevels" and "columnCollapseLevels" the collapsing + icons don't appear!

Unfortunatelly the report is an intranet application so no way to access it from the outside. I activated via F12 developer tool / Firebug on Firefox but there is no error neither in debugger nor runtime analyze.

Is it possible to make a short TeamViewer session on my machine?

PivotTable::create(array( "dataStore"=>$this->dataStore('Reporting.autorep_v_noNulls'),

"measures" => array(

"Umsatz - sum",
"Verkaufsmenge - sum",

),

"headerMap" => array(

"Umsatz - sum" => "&sum; Umsatz",
"Verkaufsmenge - sum" => "&sum; Verkaufsmenge"

),

"rowCollapseLevels" => array(1,2), "columnCollapseLevels" => array(0,1,2),

"totalName" => 'GESAMT'

));

Kind regards,

David Winterburn commented on Aug 11, 2017

Hi bysystem,

Please try removing the row and columnCollapseLevels properties altogether and send us the screenshot of the pivot table. Thanks!

bysystem commented on Aug 11, 2017

Hi David,

I just removed the row and columnCollapseLevels properties altogether:

<?php PivotTable::create(array( "dataStore"=>$this->dataStore('Reporting.autorep_v_noNulls'),

"measures" => array(

"Umsatz - sum",
"Verkaufsmenge - sum",

),

"headerMap" => array(

"Umsatz - sum" => "&sum; Umsatz",
"Verkaufsmenge - sum" => "&sum; Verkaufsmenge"

),

"totalName" => 'GESAMT'

)); ?>

Here is the screenshot without collapsing:

David Winterburn commented on Aug 11, 2017

Hi bysystem,

Please add the following css link (modify the path to suit your folder structure) to the beginning your report page:

<link rel='stylesheet' href='../../../assets/font-awesome/css/font-awesome.min.css'>

The folder font-awesome should be in the path KoolReport/examples/assets.

After adding the css link, the minus/plus icon should be there for you to collapse/expand row and column levels of the pivot table. We will find a way to add this css automatically in next version of pivot package. Thanks!

bysystem commented on Aug 11, 2017

Hi David,

thx a lot!!! It works now like a charme ;-)

Kind regards

David Winterburn commented on Aug 11, 2017

Hi bysystem,

Please ignore the previous post. It's too much work. Please add the following line to your report class like this:

class MyReport extends koolreport\KoolReport
{
  use \koolreport\clients\FontAwesome;
bysystem commented on Aug 11, 2017

Oh yes!! Much more elegant solution. Did it and it works :-)

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

Pivot