Piwik\DataTable\Filter\

ColumnCallbackAddColumnPercentage

Calculates a percentage value for each row of a DataTable and adds the result to each row.

See ColumnCallbackAddColumnQuotient for more information.

Basic usage example

$nbVisits = // ... get the visits for a period ...
$dataTable->queueFilter('ColumnCallbackAddColumnPercentage', array('nb_visits', 'nb_visits_percentage', $nbVisits, 1));

Methods

The class defines the following methods:

__construct()

Constructor.

Signature

  • It accepts the following parameter(s):

    • $table (DataTable) —

    • $columnNameToAdd (string) — The name of the column to add the quotient value to.

    • $columnValueToRead (string) — The name of the column that holds the dividend.
    • $divisorValueOrDivisorColumnName (Piwik\DataTable\Filter\number|string) — Either numeric value to use as the divisor for every row, or the name of the column whose value should be used as the divisor.
    • $quotientPrecision (int) — The precision to use when rounding the quotient.
    • $shouldSkipRows (bool|Piwik\DataTable\Filter\number) — Whether rows w/o the column to read should be skipped or not.
    • $getDivisorFromSummaryRow (bool) — Whether to get the divisor from the summary row or the current row iteration.

filter()

See ColumnCallbackAddColumnQuotient.

Signature

  • It accepts the following parameter(s):

  • It does not return anything or a mixed result.

enableRecursive()

Enables/Disables recursive filtering. Whether this property is actually used is up to the derived BaseFilter class.

Signature

  • It accepts the following parameter(s):

    • $enable (bool) —
  • It does not return anything or a mixed result.

filterSubTable()

Filters a row's subtable, if one exists and is loaded in memory.

Signature

  • It accepts the following parameter(s):
    • $row (Row) — The row whose subtable should be filter.
  • It does not return anything or a mixed result.