diff options
Diffstat (limited to 'plugins/API/RowEvolution.php')
-rw-r--r-- | plugins/API/RowEvolution.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/plugins/API/RowEvolution.php b/plugins/API/RowEvolution.php index 9025eb3436..24e695c88b 100644 --- a/plugins/API/RowEvolution.php +++ b/plugins/API/RowEvolution.php @@ -19,6 +19,7 @@ use Piwik\DataTable\Filter\SafeDecodeLabel; use Piwik\DataTable\Row; use Piwik\Period; use Piwik\Piwik; +use Piwik\Plugins\API\Filter\DataComparisonFilter; use Piwik\Site; use Piwik\Url; @@ -36,7 +37,7 @@ class RowEvolution 'getPageUrl' ); - public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label = false, $segment = false, $column = false, $language = false, $apiParameters = array(), $legendAppendMetric = true, $labelUseAbsoluteUrl = true) + public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label = false, $segment = false, $column = false, $language = false, $apiParameters = array(), $legendAppendMetric = true, $labelUseAbsoluteUrl = true, $labelSeries = '') { // validation of requested $period & $date if ($period == 'range') { @@ -49,7 +50,7 @@ class RowEvolution } $label = DataTablePostProcessor::unsanitizeLabelParameter($label); - $labels = Piwik::getArrayFromApiParameter($label); + $labels = Piwik::getArrayFromApiParameter($label, $onlyUnique = empty($labelSeries)); $metadata = $this->getRowEvolutionMetaData($idSite, $period, $date, $apiModule, $apiAction, $language, $apiParameters); @@ -72,7 +73,8 @@ class RowEvolution $labels, $column, $legendAppendMetric, - $labelUseAbsoluteUrl + $labelUseAbsoluteUrl, + $labelSeries ); } else { $data = $this->getSingleRowEvolution( @@ -420,8 +422,13 @@ class RowEvolution /** Get row evolution for a multiple labels */ private function getMultiRowEvolution(DataTable\Map $dataTable, $metadata, $apiModule, $apiAction, $labels, $column, $legendAppendMetric = true, - $labelUseAbsoluteUrl = true) + $labelUseAbsoluteUrl = true, + $labelSeries = '') { + $labelSeries = explode(',', $labelSeries); + $labelSeries = array_filter($labelSeries, 'strlen'); + $labelSeries = array_map('intval', $labelSeries); + if (!isset($metadata['metrics'][$column])) { // invalid column => use the first one that's available $metrics = array_keys($metadata['metrics']); @@ -455,6 +462,11 @@ class RowEvolution $cleanLabel = $this->cleanOriginalLabel($label); $actualLabels[$labelIdx] = $cleanLabel; } + + if (isset($labelSeries[$labelIdx])) { + $labelSeriesIndex = $labelSeries[$labelIdx]; + $actualLabels[$labelIdx] .= ' ' . DataComparisonFilter::getPrettyComparisonLabelFromSeriesIndex($labelSeriesIndex); + } } // convert rows to be array($column.'_'.$labelIdx => $value) as opposed to |