Recreate Visitsummary with custom data

Hello everybody,

I want to create a plugin which look like Visitsummary->Overview page. (Click on sparkline load the evolutionGraph).

I load my data from an other server(php/cURL).

The problem is that the sparklines are correctly displayed BUT are NOT clickable so nothing happens the evolutionGraph is not updated.


public function get( $idSite, $period, $date, $segment = false, $columns = false)

		$url     = '';

        if(strpos($date,',') === FALSE)
            $p = Piwik_Period::factory($period,Piwik_Date::factory($date));
            $p = new Piwik_Period_Range('range',$date);
        $fields = array(data.....);
       //cURL method which grep data from url
        $dataRow = $this->fetchData($url,$fields);
		// convert this array to a DataTable object
		$dataTable = new Piwik_DataTable();
		return $dataTable;


public function index()
		$view = Piwik_View::factory('index');
        $columns = Piwik_Common::getRequestVar('columns');
		$view->graphEvolutionVisitsSummary = $this->getEvolutionGraph( true, array($columns) );
		echo $view->render();
	public function getSparklines()
		$view = Piwik_View::factory('sparklines');
		echo $view->render();

	public function getEvolutionGraph( $fetch = false, $columns = false)
		$view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "TPlug.get");
			$columns = Piwik_Common::getRequestVar('columns');
		$columns = !is_array($columns) ? array($columns) : $columns;
		//$view->graphEvolutionVisitsSummary =  $this->getEvolutionGraph( true, array($columns) );
		return $this->renderView($view, $fetch);

	protected function setSparklinesAndNumbers($view)
		$view->urlSparklineNbVisits 		= $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('Cols')));
		$view->urlSparklineNbActions 		= $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('SCols')));

//Assign template variables


// ...
function getListHooksRegistered()
		$hooks = array(
			'Menu.add' => 'addMenus',
		return $hooks;

	function addMenus()
		$menus = array(
            //'Overview' => 'PlugDataTable',
            'Graph' => 'index',

		Piwik_AddMenu('Chat', '', array('module' => 'TPlug', 'action' => 'PlugDataTable'), true, 29);
		$order = 1;
		foreach($menus as $subMenu => $action) 
			Piwik_AddMenu('Chat', $subMenu, array('module' => 'TPlug', 'action' => $action, 'columns' => 'Chats'), true, $order++);

I hope that somebody can help me

Its funny even when I do an exact copy of the VisitsSummary plugin and rename only the classes and change the third parameter in Piwik_AddMenu (module => MyPlugin) it doesnt update the evolutionGraph :open_mouth:

Ok I found the problem by myself. When you want rebuild a page like VisitsSummary you have to change the first line of index.tpl (graphId).

Note : It would be better that piwik would that dynamically …

Thanks for putting the solution. Definitely there are many things that could be improved in Piwik, if you have ideas after building a plugin please let us know in a forum post your feedback (or patches)

Happy New Year! If you are still using Piwik and interested in the awesome new feature of “Creating a Custom Segment in Piwik and apply to reports in Real time!” we need YOUR help, with a little or big donation at:

This will allow to dynamically add or edit, a new set of rules for example “Show all visitors from USA and using Firefox and using Google”. This will be done via a simple to use interface. See screenshots and more info here:

We are crowd funding the future of Piwik and this feature in particular. With your help we can do it.