google_chart_colours($labels); $chart .= "&chco=$colours"; } //print_r($chart); echo "Sample chart"; } /** * chart_colours * * Creates a pie chart * * @access private * @param labels this is an array of lables for the chart * @return string */ private function google_chart_colours($labels){ $i = 0; foreach ($labels as $label){ $colours[$i] = $this->generate_colour(); $i += 1; } $colours = implode(",",$colours); return "$colours"; } /** * generate_colour * * Creates a hex colour * * @access private * @return string */ private function generate_colour (){ $length = 6; // start with a blank colour $colour = ""; // define possible characters $possible = "0123456789abcdf"; // set up a counter $i = 0; // add random characters to $colour until $length is reached while ($i < $length) { // pick a random character from the possible ones $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); $colour .= $char; $i++; } // done! return $colour; } } ?>