forked from sitracker/sitracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchart.php
More file actions
72 lines (60 loc) · 2.03 KB
/
chart.php
File metadata and controls
72 lines (60 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
// chart.php - Outputs a chart in png format using the GD library
//
// SiT (Support Incident Tracker) - Support call tracking system
// Copyright (C) 2010-2014 The Support Incident Tracker Project
// Copyright (C) 2000-2009 Salford Software Ltd. and Contributors
//
// This software may be used and distributed according to the terms
// of the GNU General Public License, incorporated herein by reference.
//
require ('core.php');
require (APPLICATION_LIBPATH . 'functions.inc.php');
// This page requires authentication
require (APPLICATION_LIBPATH . 'auth.inc.php');
plugin_do('page_start');
if (!extension_loaded('gd')) trigger_error("{$CONFIG['application_name']} requires the gd module", E_USER_ERROR);
// External variables
$type = clean_fixed_list($_REQUEST['type'], array('pie','line','bar'));
$data = explode('|',cleanvar($_REQUEST['data']));
$legends = explode('|', cleanvar($_REQUEST['legends'], TRUE, FALSE, FALSE));
$title = urldecode(cleanvar($_REQUEST['title']));
$unit = cleanvar($_REQUEST['unit']);
function __autoload($name)
{
$name = strtolower($name);
$locations = array(APPLICATION_LIBPATH . "chart_{$name}.class.php",
APPLICATION_PLUGINPATH . $name . DIRECTORY_SEPARATOR . "chart_{$name}.class.php",
APPLICATION_PLUGINPATH . $name . DIRECTORY_SEPARATOR . "{$name}.class.php");
foreach ($locations AS $l)
{
if (file_exists($l))
{
require_once ($l);
return true;
}
}
return false;
}
debug_log("Charting library being used is {$CONFIG['default_chart']}");
$chart = new $CONFIG['default_chart'](500, 150);
$chart->setTitle($title);
$chart->setData($data);
$chart->setLegends($legends);
$chart->setUnit($unit);
switch ($type)
{
case 'pie':
$chart->draw_pie_chart();
break;
case 'line':
$chart->draw_line_chart();
break;
case 'bar':
$chart->draw_bar_chart();
break;
default:
$chart->draw_error();
}
plugin_do('page_end');
?>