PHP Класс Piwik\DataTable\Filter\PivotByDimension

A pivot table is a table that displays one metric value for two dimensions. The rows of the table represent one dimension and the columns another. This filter can pivot any report by any dimension as long as either: - the pivot-by dimension is the dimension of the report's subtable - or, the pivot-by dimension has an associated report, and the report to pivot has a dimension with a segment Reports are pivoted by iterating over the rows of the report, fetching the pivot-by report for the current row, and setting the columns of row to the rows of the pivot-by report. For example: to pivot Referrers.getKeywords by UserCountry.City, we first loop through the Referrers.getKeywords report's rows. For each row, we take the label (which is the referrer keyword), and get the UserCountry.getCity report using the referrerKeyword=... segment. If the row's label were 'abcdefg', we would use the 'referrerKeyword==abcdefg' segment. The UserCountry.getCity report we find is the report on visits by country, but only for the visits for the specific row. We take this report's row labels and add them as columns for the Referrers.getKeywords table. Implementation details: Fetching intersected table can be done by segment or subtable. If the requested pivot by dimension is the report's subtable dimension, then the subtable is used regardless, since it is much faster than fetching by segment. Also, by default, fetching by segment is disabled in the config (see the '[General] pivot_by_filter_enable_fetch_by_segment' option).
Наследование: extends Piwik\DataTable\BaseFilter
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( DataTable $table, string $report, string $pivotByDimension, string | false $pivotColumn, false | integer $pivotByColumnLimit = false, boolean $isFetchingBySegmentEnabled = true ) Constructor.
filter ( DataTable $table ) Pivots to table.
getDefaultColumnLimit ( ) : integer Returns the default maximum number of columns to allow in a pivot table from the INI config.
isPivotingReportBySubtableSupported ( Report $report ) : boolean Returns true if pivoting by subtable is supported for a report. Will return true if the report has a subtable dimension and if the subtable dimension is different than the report's dimension.
isSegmentFetchingEnabledInConfig ( ) : boolean Returns true if fetching intersected tables by segment is enabled in the INI config, false if otherwise.

Приватные методы

Метод Описание
areDimensionsEqualAndNotNull ( Dimension | null $lhs, Dimension | null $rhs ) : boolean
areDimensionsNotEqualAndNotNull ( Dimension | null $lhs, Dimension | null $rhs ) : boolean
checkSupportedPivot ( )
fetchIntersectedWithThisBySegment ( DataTable $table, $segmentValue )
getColumnValue ( Row $columnRow, $pivotColumn ) : false | mixed
getIntersectedTable ( DataTable $table, Row $row ) An intersected table is a table that describes visits by a certain dimension for the visits represented by a row in another table. This method fetches intersected tables either via subtable or by using a segment. Read the class docs for more info.
getNameOfFirstNonLabelColumnInTable ( DataTable $table )
getOrderedColumnsWithPrependedNumerals ( $defaultRow, $othersRowLabel )
getPivotTableDefaultRowFromColumnSummary ( $columnSet, $othersRowLabel )
getRequestParamOverride ( DataTable $table )
isPivotDimensionSubtable ( )
loadSubtable ( DataTable $table, Row $row )
setPivotByDimension ( $pivotByDimension )
setThisReportMetadata ( $report )

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( DataTable $table, string $report, string $pivotByDimension, string | false $pivotColumn, false | integer $pivotByColumnLimit = false, boolean $isFetchingBySegmentEnabled = true )
$table Piwik\DataTable The table to pivot.
$report string The ID of the report being pivoted, eg, `'Referrers.getKeywords'`.
$pivotByDimension string The ID of the dimension to pivot by, eg, `'Referrers.Keyword'`.
$pivotColumn string | false The metric that should be displayed in the pivot table, eg, `'nb_visits'`. If `false`, the first non-label column is used.
$pivotByColumnLimit false | integer The number of columns to limit the pivot table to.
$isFetchingBySegmentEnabled boolean Whether to allow fetching by segment.

filter() публичный Метод

Pivots to table.
public filter ( DataTable $table )
$table Piwik\DataTable The table to manipulate.

getDefaultColumnLimit() публичный статический Метод

Uses the **pivot_by_filter_default_column_limit** INI config option.
public static getDefaultColumnLimit ( ) : integer
Результат integer

isPivotingReportBySubtableSupported() публичный статический Метод

Returns true if pivoting by subtable is supported for a report. Will return true if the report has a subtable dimension and if the subtable dimension is different than the report's dimension.
public static isPivotingReportBySubtableSupported ( Report $report ) : boolean
$report Piwik\Plugin\Report
Результат boolean

isSegmentFetchingEnabledInConfig() публичный статический Метод

Returns true if fetching intersected tables by segment is enabled in the INI config, false if otherwise.
public static isSegmentFetchingEnabledInConfig ( ) : boolean
Результат boolean