Open dogmatic69 opened 14 years ago
<? http://james.cridland.net/code/google-chart.html
// Here's an array containing some data to plot $test_data=array(0.5,6,12,17,2,0.3,9);
// Here's where we call the chart, and return the encoded chart data echo "<img src=http://chart.apis.google.com/chart?chtt=".urlencode("It's an example!")."&cht=lc&chs=450x125&chd=".chart_data($test_data).">";
// And here's the function
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=y&chxl=0:|0|".$maxValue; }
?>
<? http://james.cridland.net/code/google-chart.html
// Here's an array containing some data to plot $test_data=array(0.5,6,12,17,2,0.3,9);
// Here's where we call the chart, and return the encoded chart data echo "<img src=http://chart.apis.google.com/chart?chtt=".urlencode("It's an example!")."&cht=lc&chs=450x125&chd=".chart_data($test_data).">";
// And here's the function
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];
}
// Return the chart data - and let the Y axis to show the maximum value return $chartData."&chxt=y&chxl=0:|0|".$maxValue; }
?>