diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2019-05-28 03:55:17 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2019-05-28 03:55:17 +0300 |
commit | d8c99bf1462acf03a164adebf19e2d393d314091 (patch) | |
tree | 79a3a6f5449980f9d88fc029b41ddb21ba33aea3 | |
parent | dc69ca2eadae548615e5e0ab75a0a213954623c3 (diff) |
Add extra processed metrics to list of available metrics in Graph if the metadata field exists. (#14486)
-rw-r--r-- | plugins/CoreVisualizations/Visualizations/Graph.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/plugins/CoreVisualizations/Visualizations/Graph.php b/plugins/CoreVisualizations/Visualizations/Graph.php index 28ffab7768..18f5944511 100644 --- a/plugins/CoreVisualizations/Visualizations/Graph.php +++ b/plugins/CoreVisualizations/Visualizations/Graph.php @@ -10,6 +10,8 @@ namespace Piwik\Plugins\CoreVisualizations\Visualizations; use Piwik\DataTable; use Piwik\DataTable\Row; +use Piwik\Plugin\Metric; +use Piwik\Plugins\AbTesting\Columns\Metrics\ProcessedMetric; use Piwik\Plugins\CoreVisualizations\Metrics\Formatter\Numeric; use Piwik\Piwik; use Piwik\Plugin\Visualization; @@ -206,6 +208,19 @@ abstract class Graph extends Visualization $allColumns = $this->report->getAllMetrics(); } $allColumns = array_merge($allColumns, $this->getDataTable()->getColumns()); + + $dataTable = $this->getDataTable(); + if ($dataTable instanceof DataTable\Map) { + $dataTable = $dataTable->getFirstRow(); + } + + /** @var ProcessedMetric[] $extraProcessedMetrics */ + $extraProcessedMetrics = $dataTable->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME); + if (!empty($extraProcessedMetrics)) { + $extraProcessedMetricNames = array_map(function (Metric $m) { return $m->getName(); }, $extraProcessedMetrics); + $allColumns = array_merge($allColumns, $extraProcessedMetricNames); + } + $allColumns = array_unique($allColumns); // If the datatable has no data, use the default columns (there must be data for evolution graphs or else nothing displays) |