modulename = $module; chart_graphs_apis($result); //save it as a provider; } } } /** * Return the list of Graphing implementations available (if no parameter * is passed) or add a new implementation to the static list. **/ function chart_graphs_apis ( $api_class=null ) { static $apis; if (empty($apis)) $api = array(); if (!empty($api_class)) { $apis[$api_class->name] = $api_class; unset( $apis[$api_class->name]->name ); } else { return $apis; } } /** * Factory method that allows instantiating of a * charting implementation class by implementation * name. */ function chart_graphs_get_graph($name) { $apis = chart_graphs_apis(); $api = $apis[$name]; if (!empty($api) && is_object($api)) { require_once($api->path); $canvas = new $api->clazz($api->modulename); return $canvas; } else { return FALSE; } } /** Sequential generator of IDs, guaranteeing unique value per HTTP request **/ function chart_graphs_chart_id_generator() { static $id; if (empty($id)) {$id = 0;} $id++; return $id; } /** Random, unique string generator, to be used for cache_id in async data retrieval **/ function chart_graphs_random_hash() { list($usec, $sec) = explode(' ', microtime()); $seed = (float) $sec + ((float) $usec * 100000); mt_srand($seed); $randval1 = (string)mt_rand(); $randval2 = (string)mt_rand(); $randval3 = (string)mt_rand(); $rand = $randval1 . $randval2 . $randval3; $randhash = md5($rand); return "chgr_" . (string)$randhash; } /** For debugging only function charts_graphs_menu() { $items = array(); $items['charts/test'] = array( 'title' => 'Charts Test', 'page callback' => 'charts_graphs_test', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); return $items; } function charts_graphs_test() { $canvas = chart_graphs_get_graph('open-flash'); $canvas->title = "Open Flash Chart"; $canvas->type = "bar_glass"; //"bar_3d"; $canvas->y_legend = "Y Legend"; $canvas->colour = '#D54C78'; $canvas->series = array( 'Some Value' => array(9,6,7,9,5,7,6,9,7), 'Page Views' => array(6,7,9,5,7,6,9,7,3), ); $out = $canvas->get_chart(); return $out; }**/