-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchart_function.php
27 lines (21 loc) · 994 Bytes
/
chart_function.php
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
<?php
function chart_data($values) {
// Port of JavaScript from http://code.google.com/apis/chart/
// http://james.cridland.net/code
// First, find the maximum value from the values given
$maxValue = max($values);
// A list of encoding characters to help later, as per Google's example
$simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$chartData = "s:";
for ($i = 0; $i < count($values); $i++) {
$currentValue = $values[$i];
if ($currentValue > -1) {
$chartData.=substr($simpleEncoding, 61 * ($currentValue / $maxValue), 1);
} else {
$chartData.='_';
}
}
// Return the chart data - and let the Y axis to show the maximum value
return $chartData . "&chxt=x,x";
}
?>