} //Prevent error on no data if (count($datalist < 1)) { $datalist[] = 0; $labellist[] = 0; } $title = new title("Checking account forecast"); $default_dot = new dot(); $default_dot->tooltip('$#val#'); $line = new line(); $line->set_values($datalist); $line->set_default_dot_style($default_dot); $x_labels = new x_axis_labels(); $x_labels->rotate(45); $x_labels->set_labels($labellist); $x_labels->set_steps(3); $x = new x_axis(); $x->set_labels($x_labels); $y = new y_axis(); $y->set_range(min(min($datalist) - 10, 0), round(max($datalist) * 1.1)); $y->set_label_text("\$#val#"); $chart = new open_flash_chart(); $chart->set_title($title); $chart->add_element($line); $chart->set_x_axis($x); $chart->set_y_axis($y); $chart->set_bg_colour('#FFFFFF'); echo $chart->toPrettyString(); ?>
public function get_jx_json_bar($info, $type = '') { $year = array_keys($info); $price = array_values($info); $chart = new open_flash_chart(); $chart->set_bg_colour('#FFFFFF'); //flash背景颜色 $x_labels = new x_axis_labels(); $x_labels->set_steps(1); $x_labels->set_size(12); $x_labels->set_colour('#000000'); if (count($year) > 0) { $x_labels->set_vertical(); } $x_labels->set_labels($year); // // 插入数据 $x = new x_axis(); $x->set_colour('#000000'); $x->set_grid_colour('#dadada'); $x->set_offset(true); $x->set_steps(1); // Add the X Axis Labels to the X Axis $x->set_labels($x_labels); $x->set_offset(true); $chart->set_x_axis($x); // $bar = new bar_filled( '#74b1e0', '#9dc7e8' ); // $bar->set_values( $price ); $price_array = array(); foreach ($price as $k => $v) { $price_array[$k] = new bar_value($v); $price_array[$k]->set_colour('#74b1e0'); if ($type == 'percent') { //$y->set_label_text("#val#%"); $price_array[$k]->set_tooltip($year[$k] . '<br>' . '' . number_format($v) . '%'); } else { $price_array[$k]->set_tooltip($year[$k] . '<br>' . '' . number_format($v)); } } $bar = new bar_glass(); $bar->set_values($price_array); $chart->add_element($bar); // // LOOK: // //$x_legend = new x_legend( '1983 to 2008' ); //$x_legend->set_style( '{font-size: 20px; color: #778877}' ); //$chart->set_x_legend( $x_legend ); // // remove this when the Y Axis is smarter // $y = new y_axis(); $max = $this->get_the_right_y(max($price)); $max = $max > 0 ? $max : 1; $y->set_range(0, ($max / 5 + 1) * 5, $max / 5 + 1); // if ($max > 20 && $max <= 100) { // // $y->set_range(0, $max, 10); // }elseif($max >= 10&&$max<=20){ // $y->set_range(0, $max, 5); // } // else { // $y->set_range(0, $max); // } $y->set_colour('#000000'); $y->set_grid_colour('#dadada'); if ($type == 'percent') { $y->set_label_text(" #val#%"); } else { $y->set_label_text(" #val#"); } $chart->add_y_axis($y); $info = $chart->toPrettyString(); return $info; }
/** flowview_viewchart() * * This function is taken from Slowlog. Given * a title, chart type and chart data, it will * echo the required syntax for the Callback * from the chart page to operate corectly. */ function flowview_viewchart() { global $colors, $config; include $config['base_path'] . "/plugins/flowview/lib/open-flash-chart-object.php"; include $config['base_path'] . "/plugins/flowview/lib/open-flash-chart.php"; $title = $_REQUEST["title"]; $chart_type = "bar"; $column = $_REQUEST["type"]; $sessionid = $_REQUEST["session"]; /* get the chart data from the session */ if (isset($_SESSION['flowview_flows'][$sessionid]['data'])) { $data = $_SESSION['flowview_flows'][$sessionid]['data']; } else { $filter = createfilter($sessionid); $data = $_SESSION['flowview_flows'][$sessionid]['data']; } switch ($column) { case 'flows': $unit = ucfirst($column); $suffix = "Total Flows"; $_SESSION['sess_flows_flows'] = 'on'; break; case 'bytes': $unit = ucfirst($column); $suffix = "Bytes Exchanged"; $_SESSION['sess_flows_bytes'] = 'on'; break; case 'packets': $unit = ucfirst($column); $suffix = "Packets Examined"; $_SESSION['sess_flows_packets'] = 'on'; break; } $columns = $_SESSION['flowview_flows'][$sessionid]['columns']; foreach ($columns as $key => $cdata) { if (strtolower($cdata) == $column) { $column = $key; } } if (sizeof($data)) { $elements = array(); $legend = array(); $maxvalue = 0; if (isset($_REQUEST['exclude']) && $_REQUEST['exclude'] > 0) { for ($i = 0; $i < $_REQUEST['exclude']; $i++) { array_shift($data); } } foreach ($data as $row) { if ($maxvalue < $row[$column]) { $maxvalue = $row[$column]; $scaling = flowview_autoscale($row[$column]); } } $maxvalue = flowview_getmax($maxvalue); $autorange = flowview_autoscale($maxvalue); $maxvalue = $maxvalue / $autorange[0]; $i = 0; foreach ($data as $row) { $elements[$i] = new bar_value(round($row[$column] / $autorange[0], 3)); $elements[$i]->set_colour(flowview_get_color()); $elements[$i]->set_tooltip($unit . ": #val# " . $autorange[1]); if (sizeof($row) == 4) { $legend[] = $row[0]; } else { $legend[] = $row[0] . " -\n" . $row[1]; } $i++; } $bar = new bar_glass(); $bar->set_values($elements); $title = new title($title . " (" . $suffix . ")"); $title->set_style("{font-size: 18px; color: #444444; text-align: center;}"); $x_axis_labels = new x_axis_labels(); $x_axis_labels->set_size(10); $x_axis_labels->rotate(45); $x_axis_labels->set_labels($legend); $x_axis = new x_axis(); //$x_axis->set_3d( 3 ); $x_axis->set_colours('#909090', '#909090'); $x_axis->set_labels($x_axis_labels); $y_axis = new y_axis(); $y_axis->set_offset(true); $y_axis->set_colours('#909090', '#909090'); $y_axis->set_range(0, $maxvalue, $maxvalue / 10); $y_axis->set_label_text("#val# " . $autorange[1]); $chart = new open_flash_chart(); $chart->set_title($title); $chart->add_element($bar); $chart->set_x_axis($x_axis); $chart->add_y_axis($y_axis); $chart->set_bg_colour('#FEFEFE'); echo $chart->toString(); } }
srand((double) microtime() * 1000000); $data = array(); // add random height bars: for ($i = 0; $i < 10; $i++) { $data[] = rand(2, 9); } require_once '../php-ofc-library/open-flash-chart.php'; $title = new title("Penghasilan Penduduk "); $bar = new bar(); $bar->set_values($data); $bar->colour = '#D54C78'; $x_axis = new x_axis(); $x_axis->set_colour('#909090'); $x_axis->set_labels_from_array(array("Gedangan", "Sawo", "3", "4", "5", "6", "7", "8", "9", "10")); $y_axis = new y_axis(); $y_axis->set_label_text(array("Make garden look sexy", "Paint house", "Move into house")); $chart = new open_flash_chart(); $chart->set_title($title); $chart->add_element($bar); $chart->set_x_axis($x_axis); $chart->add_y_axis($y_axis); echo $chart->toPrettyString(); break; case "5": $additional = array(); $additional[] = array("key" => 'all', "value" => "All"); echo "<li><label for='kecamatan'>Kecamatan</label>"; echo select("kecamatan", "id", "nama_kecamatan", "kecamatan", 'class="ui-widget-content ui-corner-all"', "", -1, $additional); echo "</li><li><label for='kelurahan' id='lbl_desa'>Desa/Kelurahan</label></li>"; break; case "6":