Piwik\DataTable\Filter\

ColumnCallbackAddColumnQuotient

Calculates the quotient of two columns and adds the result as a new column for each row of a DataTable.

This filter is used to calculate rate values (eg, 'bounce_rate'), averages (eg, 'avg_time_on_page') and other types of values.

Basic usage example

$dataTable->queueFilter('ColumnCallbackAddColumnQuotient', array('bounce_rate', 'bounce_count', 'nb_visits', $precision = 2));

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.