$line_tot->set_width(2); $line_tot->set_key('Gesamt (kWh)', 10); $line_tot->set_tooltip("#val# kWh"); $max = max(max($data_watt), $max_val) * 1.15; $y = new y_axis(); $y->set_range(0, $max, round($max * 0.1, -1)); $x_labels = new x_axis_labels(); $x_labels->set_vertical(); $x_labels->set_steps(6); $x_labels->set_colour('#333333'); $x_labels->set_labels($time_axis); $x = new x_axis(); $x->set_colour('#333333'); $x->set_grid_colour('#ffffff'); $x->set_offset(false); $x->set_steps(3); // Add the X Axis Labels to the X Axis $x->set_labels($x_labels); $chart = new open_flash_chart(); $chart->set_tooltip($tooltip); $chart->set_title($title); //$chart->add_element( $line_max ); $chart->add_element($line_watt); $chart->add_element($bars_curr); //$chart->add_element( $line_tot ); //$chart->add_element( $sline ); $chart->set_bg_colour('#ffffff'); $chart->set_y_axis($y); $chart->set_x_axis($x); echo $chart->toString(); }
public function setGraphTitle($title) { $this->oChart->set_title(new title($title)); $this->oChart->set_tooltip($this->createTooltip()); }
private function getChart($aGraphs) { $this->prepareData(); $oLabels = new x_axis_labels(); $oLabels->set_labels($this->aData[0]); $oLabels->rotate(-45); $oX = new x_axis(); $oX->set_labels($oLabels); $oX->set_colours('#000000', '#ffffff'); $oChart = new open_flash_chart(); $oChart->set_bg_colour('#FFFFFF'); $oTitle = new title($this->getTitle()); $oTitle->set_style('font-size: 12px; font-weight: bold;'); $oChart->set_title($oTitle); $oTooltip = new tooltip('#val#'); $oTooltip->set_body_style('font-size: 10px'); $oTooltip->set_stroke(1); $oTooltip->set_shadow(true); $oTooltip->set_background_colour('#ffffcc'); $oTooltip->set_colour('#cccc99'); $oChart->set_tooltip($oTooltip); $aY = array(); foreach ($aGraphs as $k => $v) { $y = empty($v['y-right']) ? 0 : 1; $scale = empty($v['scale']) ? 1 : $v['scale']; if (!isset($aY[$y])) { $aY[$y] = new y_axis(); $aY[$y]->set_colours($v['colour'], '#f6f6f6'); } if (empty($v['y-remap'])) { $this->setAxisRange($aY[$y], $k, $scale); } else { $this->remapSeries($aY[$y], $k, $scale); } $oSeries = $this->getSeries($k, $v['type'], $v['colour']); if (!empty($this->drillDown)) { $oSeries->set_on_click($this->drillDown); } $oSeries->set_on_show($v['effect']); if ($y) { $oSeries->attach_to_right_y_axis(); } $aGraphs[$k] = $oSeries; } $oChart->set_x_axis($oX); foreach ($aY as $y => $e) { $method = $y ? 'set_y_axis_right' : 'set_y_axis'; $oChart->{$method}($e); } foreach ($aGraphs as $e) { $oChart->add_element($e); } return $oChart; }
//$posy=$posy+1; //if ($posy==6) $posy=0; } } $labels2 = new x_axis_labels(); $labels2->set_labels($tab_libelles2); $labels2->rotate(270); // Absisses $x2 = new x_axis(); //$x->set_labels( $x_labels ); $x2->set_stroke(2); $x2->set_tick_height(2); $x2->set_colour("#d000d0"); $x2->set_labels($labels2); // Tooltip du graphe ! $chart2->set_tooltip($t); $title2 = new title("Evolution par joueur"); $chart2->set_title($title2); $chart2->set_y_axis($y2); $chart2->set_x_axis($x2); $fp = fopen($fichierImage, "w"); // ouverture du fichier en écriture fputs($fp, $chart2->toPrettyString()); // on écrit les données fclose($fp); } echo "<div id=\"my_chart2\"> </div>"; ferme_base($db_link); } ?>
function stacked_bar_chart($host_instance_list) { $title = new title('所有instance实际内存使用'); $title->set_style("{color: #567300; font-size: 16px; font-weight:bold;}"); $bar_stack = new bar_stack(); $bar_stack->set_colours(array('#C4D318', '#7D7B6A')); $max = 64; foreach ($host_instance_list as $i => $instance) { $jvmmem = isset($instance['jvmmem']) ? explode('/', $instance['jvmmem']) : array(); if ($jvmmem) { foreach ($jvmmem as &$j) { $j = intval($j); } $max = $max < $jvmmem[1] ? $jvmmem[1] : $max; $jvmmem[1] = $jvmmem[1] - $jvmmem[0]; } $bar_stack->append_stack($jvmmem); $lables[] = $instance['port_num']; $services[$i] = $instance['service_name']; } $bar_stack->set_keys(array(new bar_stack_key('#C4D318', 'used', 13), new bar_stack_key('#7D7B6A', 'total', 13))); $bar_stack->set_on_click('(function(x){var services=' . json_encode($services) . ';alert(services[x]);})'); //js $bar_stack->set_tooltip('#val#M,共#total#M'); $y = new y_axis(); $y->set_range(0, $max + 32, 256); $x = new x_axis(); $x->set_labels_from_array($lables); $tooltip = new tooltip(); $tooltip->set_hover(); $chart = new open_flash_chart(); $chart->set_title($title); $chart->add_element($bar_stack); $chart->set_x_axis($x); $chart->add_y_axis($y); $chart->set_tooltip($tooltip); return $chart->toPrettyString(); }
function gsitedata() { $this->autoRender = false; $solid = $this->Session->read('sol'); $host_id = $this->Session->read('host_id'); $tinterval = 3600; $host_srch = ""; if (!empty($host_id) && $host_id != 0) { $host_srch = " AND source_id = " . $host_id; } $this->DnsMessage->recursive = -1; $site_count = $this->DnsMessage->query('SELECT hostname, COUNT(*) FROM dns_messages WHERE sol_id = ' . $solid . $host_srch . ' GROUP BY hostname ORDER BY COUNT(*) DESC LIMIT 50'); //sort($site_count); $data = array(); $x = array(); $max_resp = 0; foreach ($site_count as $site) { $data[] = array((int) $site[0]['COUNT(*)'], 0); if ($max_resp < (int) $site[0]['COUNT(*)']) { $max_resp = (int) $site[0]['COUNT(*)']; } if (empty($site[0]['hostname'])) { $x[] = (string) $site['dns_messages']['hostname']; } else { $x[] = (string) $site[0]['hostname']; } } // joson data format $title = new title(__("Host Popularity", true)); $title->set_style("{font-size: 14px; color: #990000; text-align: center; font-weight:bold;}"); $bar = new bar_stack(); $bar->set_colours(array('#e77919', '#577261')); $bar->set_on_show(new bar_on_show('grow-up', 0, 0.5)); $bar->set_values($data); $bar->set_tooltip('Host: #x_label#<br>Response #val#<br>'); $tooltip = new tooltip(); $tooltip->set_hover(); $tooltip->set_shadow(false); $tooltip->set_stroke(5); $tooltip->set_colour("#6E604F"); $tooltip->set_background_colour("#BDB396"); $data_labels = new x_axis_labels(); $data_labels->rotate(90); $data_labels->set_labels($x); $x_axis = new x_axis(); $x_axis->set_labels($data_labels); $y = new y_axis(); $y->set_range(0, $max_resp * 1.1, (int) ($max_resp / 10)); $chart = new open_flash_chart(); $chart->set_bg_colour('#F9F9F9'); $chart->set_title($title); $chart->add_element($bar); $chart->set_x_axis($x_axis); $chart->set_y_axis($y); $chart->set_tooltip($tooltip); // menu' $m = new ofc_menu("#f0E0ff", "#878787"); $m->values(array(new ofc_menu_item(__('DNS Response', true), 'go_gpage'))); $chart->set_menu($m); header("Content-Type: text/plain"); echo $chart->toPrettyString(); die; }
function generateStats($params) { global $reportCacheLocation; // Computer Statistics Generation $dbTrackHandler = connectDb(); $resultBag = generateStatsBag($params, $dbTrackHandler); // ---------------------------------------------------- // Generate charts $animation_1 = isset($params['animation_1']) ? $params['animation_1'] : 'pop'; $delay_1 = isset($params['delay_1']) ? $params['delay_1'] : 0.5; $cascade_1 = isset($params['cascade_1']) ? $params['cascade_1'] : 1; $title = new title("Genie Report: " . $params['reportName'] . " - Generated on " . date('Y/m/d h:i:s A')); $title->set_style("{font-size: 12px; color: #000000; text-align: center;}"); $bar_stack = new bar_stack(); if ($params['reportType'] == 'computerStats') { foreach ($resultBag as $elm) { $tmpTotal = $elm[AVAIBILITY_TYPE_OFFLINE] + $elm[AVAIBILITY_TYPE_AVAILABLE] + $elm[AVAIBILITY_TYPE_BUSY]; if ($tmpTotal == 0) { $tmpTotal = 1; } // Only Chuck Norris can divide by Zero. $bar_stack->append_stack(array($elm[AVAIBILITY_TYPE_OFFLINE] / $tmpTotal * 100, $elm[AVAIBILITY_TYPE_AVAILABLE] / $tmpTotal * 100, $elm[AVAIBILITY_TYPE_BUSY] / $tmpTotal * 100)); } $bar_stack->set_colours(array('#FF0000', '#00FF00', '#A25B00')); $bar_stack->set_keys(array(new bar_stack_key('#FF0000', 'OFFLINE', 13), new bar_stack_key('#00FF00', 'FREE', 13), new bar_stack_key('#A25B00', 'BUSY', 13))); } else { $allProgNames = array(); foreach ($resultBag as $elm) { $progNames = array_keys($elm); foreach ($progNames as $progName) { if (validProgram($progName)) { if (!array_key_exists($progName, $allProgNames)) { $allProgNames[$progName] = "#" . dechex(rand(0, 10000000)); } } } } $progsArray = array(); foreach ($resultBag as $elm) { $tmpTotal = 0; $progNames = array_keys($elm); foreach ($elm as $programName => $programWeight) { if (validProgram($programName)) { $tmpTotal += $programWeight; } } //echo "<h1>$tmpTotal</h1>"; if ($tmpTotal == 0) { $tmpTotal = 1; } // Only Chuck Norris can divide by Zero. $progs = array(); foreach ($elm as $programName => $programWeight) { if (validProgram($programName)) { $percentVal = $programWeight / $tmpTotal * 100; $progs[] = new bar_stack_value($percentVal, $allProgNames[$programName]); $progsArray[$percentVal * 1000000] = $programName; } } $bar_stack->append_stack($progs); } $legends = array(); //$strAllProgNames = array_keys($allProgNames); foreach ($allProgNames as $programName => $programColor) { $legends[] = new bar_stack_key($programColor, $programName, 13); } $bar_stack->set_keys($legends); ksort($progsArray); echo "<pre>"; while (list($key, $value) = each($progsArray)) { $kw = $key / 1000000; echo "{$kw}: {$value}<br />\n"; } echo "</pre>"; } //$bar_stack->set_tooltip( 'In #x_label# you get #total# days holiday a year.<br>Number of days: #val#' ); $bar_stack->set_on_show(new bar_on_show($animation_1, $cascade_1, $delay_1)); $y = new y_axis(); $y->set_range(0, 100, 10); //$y->set_range( 0, $tmpMax, $tmpMax/10 ); $x_labels = new x_axis_labels(); $x_labels->rotate(45); $x_labels->set_labels(array_keys($resultBag)); $x = new x_axis(); $x->set_labels($x_labels); $tooltip = new tooltip(); $tooltip->set_hover(); $chart = new open_flash_chart(); $chart->set_title($title); $chart->add_element($bar_stack); $chart->set_x_axis($x); $chart->add_y_axis($y); $chart->set_tooltip($tooltip); // ---------------------------------------------------- $cacheid = time(); $filename = $cacheid . '.cache.json'; $myFile = "{$reportCacheLocation}/reports-cache/" . $filename; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $chart->toPrettyString()); fclose($fh); return $cacheid; }