Piwik\Plugins\CoreHome\Columns\Metrics\

EvolutionMetric

Calculates evolution values for any other metric.

An evolution is the percent change from a point in the past to the present. They are computed as:

(current value - value in past) / value in past

Methods

The class defines the following methods:

compute()

Computes the metric using the values in a Row.

The computed value should be numerical and not formatted in any way. For example, for a percent value, 0.14 should be returned instead of "14%".

Signature

  • It accepts the following parameter(s):

    • $row (Row) —
  • It returns a mixed value.

getDependentMetrics()

Returns the array of metrics that are necessary for computing this metric.

The elements of the array are metric names.

Signature

  • It returns a string[] value.

getTemporaryMetrics()

Returns the array of metrics that are necessary for computing this metric, but should not be displayed to the user unless explicitly requested.

These metrics are intermediate metrics that are not really valuable to the user. On a request, if showColumns or hideColumns is not used, they will be removed automatically.

Signature

  • It returns a string[] value.

beforeCompute()

Executed before computing all processed metrics for a report.

Implementers can return false to skip computing this metric.

Signature

  • It accepts the following parameter(s):

  • Returns: bool — Return true to compute the metric for the table, false to skip computing this metric.

__construct()

Constructor.

Signature

  • It accepts the following parameter(s):
    • $wrapped (string|Metric) — The metric used to calculate the evolution.
    • $pastData (DataTable) — The data in the past to use when calculating evolutions.
    • $evolutionMetricName (string|Piwik\Plugins\CoreHome\Columns\Metrics\false) — The name of the evolution processed metric. Defaults to $wrapped's name with '_evolution' appended.
    • $quotientPrecision (int) — The percent's quotient precision.

getName()

Signature

  • It does not return anything.

getTranslatedName()

Signature

  • It does not return anything.

format()

Signature

  • It accepts the following parameter(s):

  • It does not return anything.

beforeComputeSubtable()

Signature

  • It accepts the following parameter(s):

    • $row (Row) —
  • It does not return anything.

afterComputeSubtable()

Signature

  • It accepts the following parameter(s):

    • $row (Row) —
  • It does not return anything.

getPastRowFromCurrent()

public for Insights use.

Signature

  • It accepts the following parameter(s):

    • $row (Row) —
  • It does not return anything.