本文整理汇总了PHP中Piwik\Piwik::getPercentageSafe方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::getPercentageSafe方法的具体用法?PHP Piwik::getPercentageSafe怎么用?PHP Piwik::getPercentageSafe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Piwik
的用法示例。
在下文中一共展示了Piwik::getPercentageSafe方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setSparklinesAndNumbers
protected function setSparklinesAndNumbers($view)
{
$view->urlSparklineNbVisitsReturning = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_visits_returning')));
$view->urlSparklineNbActionsReturning = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_actions_returning')));
$view->urlSparklineActionsPerVisitReturning = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_actions_per_visit_returning')));
$view->urlSparklineAvgVisitDurationReturning = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('avg_time_on_site_returning')));
$view->urlSparklineBounceRateReturning = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('bounce_rate_returning')));
$dataTableFrequency = $this->getSummary();
$dataRow = $dataTableFrequency->getFirstRow();
$nbVisitsReturning = $dataRow->getColumn('nb_visits_returning');
$view->nbVisitsReturning = $nbVisitsReturning;
$view->nbActionsReturning = $dataRow->getColumn('nb_actions_returning');
$view->nbActionsPerVisitReturning = $dataRow->getColumn('nb_actions_per_visit_returning');
$view->avgVisitDurationReturning = $dataRow->getColumn('avg_time_on_site_returning');
$nbBouncedReturningVisits = $dataRow->getColumn('bounce_count_returning');
$view->bounceRateReturning = Piwik::getPercentageSafe($nbBouncedReturningVisits, $nbVisitsReturning);
}
示例2: formatValue
/**
* Formats the given value as a percentage.
*
* @param number $value
* @param number $divisor
* @return string
*/
protected function formatValue($value, $divisor)
{
return Piwik::getPercentageSafe($value, $divisor, $this->quotientPrecision) . '%';
}
示例3: setSparklinesAndNumbers
protected function setSparklinesAndNumbers($view)
{
$view->urlSparklineNbVisits = $this->getUrlSparkline('getEvolutionGraph', array('columns' => $view->displayUniqueVisitors ? array('nb_visits', 'nb_uniq_visitors') : array('nb_visits')));
$view->urlSparklineNbPageviews = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_pageviews', 'nb_uniq_pageviews')));
$view->urlSparklineNbDownloads = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_downloads', 'nb_uniq_downloads')));
$view->urlSparklineNbOutlinks = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_outlinks', 'nb_uniq_outlinks')));
$view->urlSparklineAvgVisitDuration = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('avg_time_on_site')));
$view->urlSparklineMaxActions = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('max_actions')));
$view->urlSparklineActionsPerVisit = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_actions_per_visit')));
$view->urlSparklineBounceRate = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('bounce_rate')));
$view->urlSparklineAvgGenerationTime = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('avg_time_generation')));
$idSite = Common::getRequestVar('idSite');
$displaySiteSearch = Site::isSiteSearchEnabledFor($idSite);
if ($displaySiteSearch) {
$view->urlSparklineNbSearches = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_searches', 'nb_keywords')));
}
$view->displaySiteSearch = $displaySiteSearch;
$dataTableVisit = self::getVisitsSummary();
$dataRow = $dataTableVisit->getRowsCount() == 0 ? new Row() : $dataTableVisit->getFirstRow();
$view->nbUniqVisitors = (int) $dataRow->getColumn('nb_uniq_visitors');
$nbVisits = (int) $dataRow->getColumn('nb_visits');
$view->nbVisits = $nbVisits;
$view->averageVisitDuration = $dataRow->getColumn('avg_time_on_site');
$nbBouncedVisits = $dataRow->getColumn('bounce_count');
$view->bounceRate = Piwik::getPercentageSafe($nbBouncedVisits, $nbVisits);
$view->maxActions = (int) $dataRow->getColumn('max_actions');
$view->nbActionsPerVisit = $dataRow->getColumn('nb_actions_per_visit');
if (Common::isActionsPluginEnabled()) {
$view->showActionsPluginReports = true;
$dataTableActions = APIActions::getInstance()->get($idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), \Piwik\API\Request::getRawSegmentFromRequest());
$dataActionsRow = $dataTableActions->getRowsCount() == 0 ? new Row() : $dataTableActions->getFirstRow();
$view->nbPageviews = (int) $dataActionsRow->getColumn('nb_pageviews');
$view->nbUniquePageviews = (int) $dataActionsRow->getColumn('nb_uniq_pageviews');
$view->nbDownloads = (int) $dataActionsRow->getColumn('nb_downloads');
$view->nbUniqueDownloads = (int) $dataActionsRow->getColumn('nb_uniq_downloads');
$view->nbOutlinks = (int) $dataActionsRow->getColumn('nb_outlinks');
$view->nbUniqueOutlinks = (int) $dataActionsRow->getColumn('nb_uniq_outlinks');
$view->averageGenerationTime = $dataActionsRow->getColumn('avg_time_generation');
if ($displaySiteSearch) {
$view->nbSearches = (int) $dataActionsRow->getColumn('nb_searches');
$view->nbKeywords = (int) $dataActionsRow->getColumn('nb_keywords');
}
// backward compatibility:
// show actions if the finer metrics are not archived
$view->showOnlyActions = false;
if ($dataActionsRow->getColumn('nb_pageviews') + $dataActionsRow->getColumn('nb_downloads') + $dataActionsRow->getColumn('nb_outlinks') == 0 && $dataRow->getColumn('nb_actions') > 0) {
$view->showOnlyActions = true;
$view->nbActions = $dataRow->getColumn('nb_actions');
$view->urlSparklineNbActions = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('nb_actions')));
}
}
}
示例4: addFilter_percentage
protected function addFilter_percentage()
{
$percentage = new Twig_SimpleFilter('percentage', function ($string, $totalValue, $precision = 1) {
return Piwik::getPercentageSafe($string, $totalValue, $precision) . '%';
});
$this->twig->addFilter($percentage);
}
示例5: addFilter_percentage
protected function addFilter_percentage()
{
$percentage = new Twig_SimpleFilter('percentage', function ($string, $totalValue, $precision = 1) {
$formatter = NumberFormatter::getInstance();
return $formatter->formatPercent(Piwik::getPercentageSafe($string, $totalValue, $precision), $precision);
});
$this->twig->addFilter($percentage);
}
示例6: getTotalEvolution
private function getTotalEvolution($totalValue, $lastTotalValue)
{
return Piwik::getPercentageSafe($totalValue - $lastTotalValue, $lastTotalValue, 1);
}