1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\CoreHome\DataTableRowAction;
use Piwik\Common;
use Piwik\Context;
use Piwik\Piwik;
/**
* MULTI ROW EVOLUTION
* The class handles the popover that shows the evolution of a multiple rows in a data table
*/
class MultiRowEvolution extends RowEvolution
{
/** The requested metric */
protected $metric;
/** Show all metrics in the evolution graph when the popover opens */
protected $initiallyShowAllMetrics = true;
/** The metrics available in the metrics select */
protected $metricsForSelect;
/**
* The constructor
* @param int $idSite
* @param \Piwik\Date $date ($this->date from controller)
*/
public function __construct($idSite, $date, $graphType = 'graphEvolution')
{
$this->metric = Common::getRequestVar('column', '', 'string');
parent::__construct($idSite, $date, $graphType);
}
protected function loadEvolutionReport($column = false)
{
// set the "column" parameter for the API.getRowEvolution call
parent::loadEvolutionReport($this->metric);
}
protected function extractEvolutionReport($report)
{
$this->metric = $report['column'];
$this->dataTable = $report['reportData'];
$this->availableMetrics = $report['metadata']['metrics'];
$this->metricsForSelect = $report['metadata']['columns'];
$this->dimension = $report['metadata']['dimension'];
}
/**
* Render the popover
* @param \Piwik\Plugins\CoreHome\Controller $controller
* @param \Piwik\View (the popover_rowevolution template)
*/
public function renderPopover($controller, $view)
{
// add data for metric select box
$view->availableMetrics = $this->metricsForSelect;
$view->selectedMetric = $this->metric;
$view->availableRecordsText = $this->dimension . ': '
. Piwik::translate('RowEvolution_ComparingRecords', array(count($this->availableMetrics)));
return parent::renderPopover($controller, $view);
}
protected function getRowEvolutionGraphFromController(\Piwik\Plugins\CoreHome\Controller $controller)
{
// the row evolution graphs should not compare serieses
return Context::executeWithQueryParameters(['compareSegments' => [], 'comparePeriods' => [], 'compareDates' => []], function () use ($controller) {
return parent::getRowEvolutionGraphFromController($controller);
});
}
public function getRowEvolutionGraph($graphType = false, $metrics = false)
{
// the row evolution graphs should not compare serieses
return Context::executeWithQueryParameters(['compareSegments' => [], 'comparePeriods' => [], 'compareDates' => []], function () use ($graphType, $metrics) {
return parent::getRowEvolutionGraph($graphType, $metrics);
});
}
protected function getSparkline($metric)
{
// the row evolution graphs should not compare serieses
return Context::executeWithQueryParameters(['compareSegments' => [], 'comparePeriods' => [], 'compareDates' => []], function () use ($metric) {
return parent::getSparkline($metric);
});
}
}
|