Sparklines dont work in dashboard

After I’ve updated from 1.9 to 1.9.1, sparklines stopped working in dashboard. There is no dashboard widget where they work but everywhere else they work fine. I found out that incorrect sparkline URLs are generated by dashboard.

Incorrect sparkline urls generated by dashboard have idSite and period parameters missing:

URLs should be like this instead (when I fix the url myself, server returns a perferct sparkline):

BTW, how to hide backtrace in error messages? If it is not possible (it should be because backtraces are hidden on demo version), then tell me where is the code that displays them, and i will simply comment out that code. Thanks.

do you see an error messagE? can you see the problem on the demo as well ? I cant reproduce so far

When dashboard requests invalid url (viewDataTable=sparkline&action=getEvolutionGraph&module=VisitsSummary&columns=nb_visits,nb_uniq_visitors&date=2012-09-27,2012-10-26), it returns this:

After I manually added idSite, another error occured (viewDataTable=sparkline&action=getEvolutionGraph&module=VisitsSummary&columns=nb_visits,nb_uniq_visitors&date=2012-09-26,2012-10-25&idSite=1):

After I added period parameter, it finally returned good sparkline (viewDataTable=sparkline&action=getEvolutionGraph&module=VisitsSummary&columns=nb_visits,nb_uniq_visitors&date=2012-09-26,2012-10-25&idSite=1&period=day)

Again, the problem appears only in dashboard widgets. In Visitors tab or All Websites Dashboard, sparklines work well.

I dont know what happened - I cleaned the cache, and reploaded most of the files and still did not get it fixed.

I also have the same problem after upgrading, so definitely not isolated.

Thanks for the report. I cannot reproduce. If you create a new dashboard, do you stlil experience the sparkline not working issue?

(I’d no idea you could create a new dashboard!)
Yes, still the same problem on the new dashboard.

Yay! I fixed sparklines for VisitsSummary!

I did a dirty hack here: /trunk/plugins/VisitsSummary/Controller.php, line 110
This is the new code of the setSparklinesAndNumbers() method:

protected function setSparklinesAndNumbers($view)
	[u]$idSite = Piwik_Common::getRequestVar('idSite');[/u]
	[u]$period = Piwik_Common::getRequestVar('period');[/u]
	$view->urlSparklineNbVisits 		= $this->getUrlSparkline( 'getEvolutionGraph', array([b]'idSite' => $idSite, 'period' => $period,[/b] 'columns' => $view->displayUniqueVisitors ? array('nb_visits', 'nb_uniq_visitors') : array('nb_visits')));
	$view->urlSparklineNbPageviews 		= $this->getUrlSparkline( 'getEvolutionGraph', array([b]'idSite' => $idSite, 'period' => $period,[/b] 'columns' => array('nb_pageviews', 'nb_uniq_pageviews')));
	$view->urlSparklineNbDownloads 	    = $this->getUrlSparkline( 'getEvolutionGraph', array([b]'idSite' => $idSite, 'period' => $period,[/b] 'columns' => array('nb_downloads', 'nb_uniq_downloads')));
	$view->urlSparklineNbOutlinks 		= $this->getUrlSparkline( 'getEvolutionGraph', array([b]'idSite' => $idSite, 'period' => $period,[/b] 'columns' => array('nb_outlinks', 'nb_uniq_outlinks')));
	$view->urlSparklineAvgVisitDuration = $this->getUrlSparkline( 'getEvolutionGraph', array([b]'idSite' => $idSite, 'period' => $period,[/b] 'columns' => array('avg_time_on_site')));
	$view->urlSparklineMaxActions 		= $this->getUrlSparkline( 'getEvolutionGraph', array([b]'idSite' => $idSite, 'period' => $period,[/b] 'columns' => array('max_actions')));
	$view->urlSparklineActionsPerVisit 	= $this->getUrlSparkline( 'getEvolutionGraph', array([b]'idSite' => $idSite, 'period' => $period,[/b] 'columns' => array('nb_actions_per_visit')));
	$view->urlSparklineBounceRate 		= $this->getUrlSparkline( 'getEvolutionGraph', array([b]'idSite' => $idSite, 'period' => $period,[/b] 'columns' => array('bounce_rate')));
	$displaySiteSearch = Piwik_Site::isSiteSearchEnabledFor($idSite);
		$view->urlSparklineNbSearches 	= $this->getUrlSparkline( 'getEvolutionGraph', array([b]'idSite' => $idSite, 'period' => $period,[/b] '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');

		$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([b]'idSite' => $idSite, 'period' => $period,[/b] 'columns' => array('nb_actions')));

dfsdfsdfsdf, or someone else trying this, can you please create a ticket at and post the patch for this issue? See:


Ticket #3483. Sorry for not using diff.

EDIT: problem was fixed by SteveG. Diff:

No, it is not completely fixed. Using both Controller.php files from trunk and the new widgetMenu.js no sparkline will appear in my Dashboard, neither in an old dashboard nor in a newly created one. (Browser cache has been cleared before and after each test.)

Now the error message is:

#0 /statistik/plugins/VisitsSummary/Controller.php(77): Piwik_Common::getRequestVar('idSite')
#1 /statistik/core/FrontController.php(138): Piwik_VisitsSummary_Controller->getEvolutionGraph()
#2 /statistik/index.php(53): Piwik_FrontController->dispatch(Array, Array)
#3 {main}

“I can’t reproduce” and “it works in our demo” definitely is not a good reason to publish a new release of Piwik.

1.9.1 is definitely completely messed up - never before have I seen so many complaints and bug reports.

I agree and it surely wasn’t the reason to publish a new release.
But if the developer can’t reproduce an issue its really hard to fix it and he needs help of the users who have this issue in their specific environment.
Its like looking into a crystal ball …

Sorry about the trouble about these bugs. Check out the latest release:

It still has some bugs, but many less, let us know if you find any more.

Thanks, 1.9.2-b2 fixes the sparkline issue - at least for my installations.