Opened 18 months ago

Closed 18 months ago

Last modified 11 months ago

#3483 closed Bug (fixed)

Sparklines dont work in dashboard

Reported by: dfsdfsdfsdf Owned by: capedfuzz
Priority: normal Milestone: 1.9.2 - Piwik 1.9.2
Component: Core Keywords:
Cc: Sensitive: no

Description

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 http://dev.piwik.org/trac/browser/trunk/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')));
    }
}

Change History (8)

comment:1 Changed 18 months ago by matt (mattab)

  • Owner set to capedfuzz

Thanks for the report & patch dfsdfsdfsdf

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

comment:2 Changed 18 months ago by dfsdfsdfsdf

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

http://dev.piwik.org/trac/browser/trunk/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.

comment:3 Changed 18 months ago by SteveG (sgiehl)

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:4 Changed 18 months ago by dfsdfsdfsdf

That fixed all sparklines in dashboard. Thanks, SteveG.

comment:5 Changed 18 months ago by matt (mattab)

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

comment:6 Changed 18 months ago by p_nuts

actually this is just a half fix.

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

comment:7 Changed 18 months ago by SteveG (sgiehl)

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

comment:8 Changed 11 months ago by pebosi

Note: See TracTickets for help on using tickets.