@anonymous-matomo-user opened this Issue on October 27th 2012

After I've updated from 1.9 to 1.9.1, sparklines stopped working in dashboard. Everywhere else sparklines work fine.

Incorrect URLs are generated by dashboard widgets (idSite and period parameters are missing): viewDataTable=sparkline&action=getEvolutionGraph&module=VisitsSummary&columns=nb_visits,nb_uniq_visitors&date=2012-09-27,2012-10-26), it returns this:

I have changed method setSparklinesAndNumbers() in [https://github.com/piwik/piwik/blob/master/plugins/VisitsSummary/Controller.php#L110] and it fixed the problem for VisitsSummary plugin:

protected function setSparklinesAndNumbers($view)
{
->  $idSite = Piwik_Common::getRequestVar('idSite');
->  $period = Piwik_Common::getRequestVar('period');

->  $view->urlSparklineNbVisits         = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => $view->displayUniqueVisitors ? array('nb_visits', 'nb_uniq_visitors') : array('nb_visits')));
->  $view->urlSparklineNbPageviews      = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('nb_pageviews', 'nb_uniq_pageviews')));
->  $view->urlSparklineNbDownloads      = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('nb_downloads', 'nb_uniq_downloads')));
->  $view->urlSparklineNbOutlinks       = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('nb_outlinks', 'nb_uniq_outlinks')));
->  $view->urlSparklineAvgVisitDuration = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('avg_time_on_site')));
->  $view->urlSparklineMaxActions       = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('max_actions')));
->  $view->urlSparklineActionsPerVisit  = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('nb_actions_per_visit')));
->  $view->urlSparklineBounceRate       = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('bounce_rate')));

    $displaySiteSearch = Piwik_Site::isSiteSearchEnabledFor($idSite);
    if($displaySiteSearch)
    {
->      $view->urlSparklineNbSearches = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('nb_searches', 'nb_keywords')));
    }
    $view->displaySiteSearch = $displaySiteSearch;

    $dataTableVisit = self::getVisitsSummary();
    $dataRow = $dataTableVisit->getRowsCount() == 0 ? new Piwik_DataTable_Row() : $dataTableVisit->getFirstRow();

->  $dataTableActions = Piwik_Actions_API::getInstance()->get($idSite, $period, Piwik_Common::getRequestVar('date'), Piwik_Common::getRequestVar('segment',false));
    $dataActionsRow =
        $dataTableActions->getRowsCount() == 0 ? new Piwik_DataTable_Row() : $dataTableActions->getFirstRow();

    $view->nbUniqVisitors = (int)$dataRow->getColumn('nb_uniq_visitors');
    $nbVisits = (int)$dataRow->getColumn('nb_visits');
    $view->nbVisits = $nbVisits;
    $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->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($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('idSite' => $idSite, 'period' => $period, 'columns' => array('nb_actions')));
    }
}
@mattab commented on October 27th 2012 Member

Thanks for the report & patch dfsdfsdfsdf

capedfuzz please try reproduce (I couldn't) or apply change after double checking. Thx!

@anonymous-matomo-user commented on October 27th 2012

Another "patch" for VisitFrequency plugin - now all sparklines in my dashboard work well.

[https://github.com/piwik/piwik/blob/master/plugins/VisitFrequency/Controller.php#L80]

protected function setSparklinesAndNumbers($view)
{
->  $idSite = Piwik_Common::getRequestVar('idSite');
->  $period = Piwik_Common::getRequestVar('period');

->  $view->urlSparklineNbVisitsReturning         = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('nb_visits_returning')));
->  $view->urlSparklineNbActionsReturning        = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('nb_actions_returning')));
->  $view->urlSparklineActionsPerVisitReturning  = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('nb_actions_per_visit_returning')));
->  $view->urlSparklineAvgVisitDurationReturning = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, 'columns' => array('avg_time_on_site_returning')));
->  $view->urlSparklineBounceRateReturning       = $this->getUrlSparkline('getEvolutionGraph', array('idSite' => $idSite, 'period' => $period, '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);
}

PS: IMHO, the problem is not in these plugins because there are many getUrlSparkline() calls in other places, w/o 'idSite' and 'period' set, and in these places sparklines work as they should. Anyway, these "patches" are good temporary solution.

@sgiehl commented on October 27th 2012 Member

(In [7317]) fixes #3483, refs #3359 use GET to query for widgets as query string is used to build urls for sparklines

@anonymous-matomo-user commented on October 27th 2012

That fixed all sparklines in dashboard. Thanks, SteveG.

@mattab commented on October 30th 2012 Member

(In [7324]) Refs #3483 would be nice to include all recent fixes in a new clean release!

@anonymous-matomo-user commented on November 9th 2012

actually this is just a half fix.

when the dashboard is used as an iframe or through API the sparkline fail

@sgiehl commented on November 9th 2012 Member

Sparklines work fine for me within embedded dashboard. Are other sparklines working on your installation?

@pebosi commented on May 27th 2013 Contributor

@p_nuts see this ticket #3915

This Issue was closed on May 27th 2013
Powered by GitHub Issue Mirror