subtracts 500 caouse it draws from the top //----------> this is for the google api $num_loc_[$i] = ceil((($num_loc_[$i]/$numCity)*500)); $i++; } $string = ''; foreach($city_ as $key => $value){ $string .="$value|"; } $string = str_replace(' ', '', $string); // *********** THE $num_loc_ VARIABLE DOES NOT TO BE JOINED INTO AN ARRAY! $test_data = $num_loc_; // Here's where we call the chart, and return the encoded chart data //dynamic graph witdh $graphWidth = ((50*$totalCityNum)+100); echo ""; //inserting into the database to keep track of the charts $chartInsert="INSERT INTO `emoChart` (`chartType`, `url`,`date`) VALUES ('inputCity','$url','$now')"; $resultInsert=mysql_query($chartInsert); // And here's the function that incodes the graph values into a Google Chart API readable format. 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 = 500; // 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; } ?>