tiki-pv_chart.php 1.1 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
2
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
3
// 
4 5
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6
// $Id$
changi67's avatar
changi67 committed
7

8
require_once ('tiki-setup.php');
9 10
$access->check_feature('feature_stats');
$access->check_permission('tiki_p_view_stats');
11 12 13
require_once ("lib/graph-engine/gd.php");
require_once ("lib/graph-engine/graph.multiline.php");

lrargerich's avatar
lrargerich committed
14
//Define the object
15 16
$renderer = new GD_GRenderer(450, 300);
$graph = new MultilineGraphic;
changi67's avatar
changi67 committed
17
$graph->setTitle(tra('Pageviews'));
lrargerich's avatar
lrargerich committed
18
//Set some data
changi67's avatar
changi67 committed
19
if (!isset($_REQUEST["days"])) $_REQUEST["days"] = 7;
20 21 22 23

$statslib = TikiLib::lib('stats');
$data = $statslib->get_pv_chart_data($_REQUEST["days"]);

24
foreach ($data['xdata'] as $key => $date) {
25 26
	 $data['xdata'][$key] = strtotime($date) / 24 / 3600;
}
changi67's avatar
changi67 committed
27 28 29 30 31
$graph->setData(array('x' => $data['xdata'], 'y0' => $data['ydata']));
$graph->setParam('grid-independant-major-font', false);
$graph->setParam('grid-independant-major-guide', false);
$graph->draw($renderer);
$renderer->httpOutput('stats.png');