/** * init Graph : Show Titles / Date selector * * @params $options ($rand, short_classname, title, desc, delay) */ function initGraph($options) { global $LANG, $CFG_GLPI; $width = $this->width + 100; $randname = $options['randname']; echo "<div class='center'><div id='fig' style='width:{$width}px'>"; //Show global title if (isset($LANG['plugin_mreporting'][$options['short_classname']]['title'])) { echo "<div class='graph_title'>"; echo $LANG['plugin_mreporting'][$options['short_classname']]['title']; echo "</div>"; } //Show graph title echo "<div class='graph_title'>"; $backtrace = debug_backtrace(); $prev_function = strtolower(str_replace('show', '', $backtrace[1]['function'])); echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/mreporting/pics/chart-{$prev_function}.png' class='title_pics' />"; echo $options['title']; echo "</div>"; $desc = ''; if (!empty($options['desc'])) { $desc = $options['desc']; } if (!empty($options['desc']) && isset($_REQUEST['date1' . $randname]) && isset($_REQUEST['date1' . $randname])) { $desc .= " - "; } if (isset($_REQUEST['date1' . $randname]) && isset($_REQUEST['date1' . $randname])) { $desc .= Html::convdate($_REQUEST['date1' . $randname]) . " / " . Html::convdate($_REQUEST['date2' . $randname]); } echo "<div class='graph_desc'>" . $desc . "</div>"; //Show date selector //using rand for display x graphs on same page if (!isset($_REQUEST['date1' . $randname])) { $_REQUEST['date1' . $randname] = strftime("%Y-%m-%d", time() - $options['delay'] * 24 * 60 * 60); } if (!isset($_REQUEST['date2' . $randname])) { $_REQUEST['date2' . $randname] = strftime("%Y-%m-%d"); } echo "<div class='graph_navigation'>"; PluginMreportingMisc::showSelector($_REQUEST['date1' . $randname], $_REQUEST['date2' . $randname], $randname); echo "</div>"; $ex_func = explode($options['short_classname'], $options['randname']); if (!is_numeric($ex_func[0])) { $classname = $ex_func[0] . $options['short_classname']; $functionname = $ex_func[1]; // We check if a configuration is needed for the graph if (method_exists(new $classname(), 'needConfig')) { $configs = PluginMreportingConfig::initConfigParams($functionname, $classname); $object = new $classname(); $object->needConfig($configs); } } //Script for graph display if ($randname !== false) { echo "<div class='graph' id='graph_content{$randname}'>"; $colors = "'" . implode("', '", PluginMreportingConfig::getColors()) . "'"; echo "<script type='text/javascript+protovis'>\n function showGraph{$randname}() {\n colors = pv.colors({$colors});"; } }
static function getColors($index = 20) { $colors = PluginMreportingConfig::getColors($index); foreach ($colors as &$color) { $color = str_replace('#', '', $color); } return $colors; }