public static function create_area_graph($title) { self::init(); $d = new solid_dot(); $d->size(3)->halo_size(1)->colour('#3D5C56'); $range_values = array(); foreach (self::$data_set as $data) { if (!is_array($data['values'])) { continue; } $area = new area(); // set the circle line width: $area->set_width(2); $area->set_default_dot_style($d); $area->set_colour($data['color']); $area->set_fill_colour($data['color']); $area->set_fill_alpha(0.3); $area->on_show(new line_on_show('pop-up', 2, 0.5)); $area->set_key($data['line_title'], 10); $area->set_values($data['values']); # Since there should be an even number on the xaxis for all sets $x_axis_titles = $data['titles']; # Add our values into a big bucket so we can get the highest and lowest $range_values = array_merge($range_values, $data['values']); self::$chart->add_element($area); } $x_labels = new x_axis_labels(); $x_labels->set_labels($x_axis_titles); $x_labels->set_vertical(); self::$x_axis->set_labels($x_labels); $range = self::get_range($range_values); self::$y_axis->set_range($range['min'], $range['max']); self::show_chart($title); }
/** * Creates a preconfigured area element (colors etc.) * */ protected function createArea($color = '#f58615', $fill_color = '#fcdeba') { $dot = $this->createDot($color); $area = new area(); // set the circle line width: $area->set_width(2); $area->set_default_dot_style($dot); $area->set_colour($color); $area->set_fill_colour($fill_color); $area->set_fill_alpha(0.8); return $area; }
<?php $data = array(); for ($i = 0; $i < 6.2; $i += 0.2) { $tmp = sin($i) * 1.9; $data[] = $tmp; } include '../php-ofc-library/open-flash-chart.php'; $chart = new open_flash_chart(); $chart->set_title(new title('Area Chart')); // // Make our area chart: // $area = new area(); // set the circle line width: $area->set_width(2); $area->set_default_dot_style(new hollow_dot()); $area->set_colour('#838A96'); $area->set_fill_colour('#E01B49'); $area->set_fill_alpha(0.4); $area->set_values($data); // add the area object to the chart: $chart->add_element($area); $y_axis = new y_axis(); $y_axis->set_range(-2, 2, 2); $y_axis->labels = null; $y_axis->set_offset(false); $x_axis = new x_axis(); $x_axis->labels = $data; $x_axis->set_steps(2); $x_labels = new x_axis_labels();
$line_max->set_default_dot_style($line_max_default_dot); $line_max->set_values( $data_max ); $line_max->set_colour( '#FEE88F' ); $line_max->set_width( 1 ); $line_max->set_key( 'Max (W)', 10 ); $line_max->set_tooltip( "#val# W" ); */ $line_watt_default_dot = new dot(); $line_watt_default_dot->size(4)->colour('#f00000'); $line_watt = new area(); $line_watt->set_default_dot_style($line_watt_default_dot); $line_watt->set_values($data_watt); $line_watt->set_colour('#4D4D4D'); $line_watt->set_fill_colour('#EFC01D'); $line_watt->set_fill_alpha(0.75); $line_watt->set_width(2); $line_watt->set_key('Leistung (W)', 10); $line_watt->set_tooltip("#val# W"); $line_tot_default_dot = new dot(); $line_tot_default_dot->size(4)->halo_size(2); $line_tot = new line(); $line_tot->set_default_dot_style($line_tot_default_dot); $line_tot->set_values($data_tot); $line_tot->set_colour('#A0A000'); $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();
function indexAction() { // $this->_helper->layout->disableLayout(); // $login = "******"; // $password = "******"; // include_once 'sina.php'; // $resultarray = get_sinacontacts($login, $password); // Zend_Debug::dump($resultarray); // include_once '163.php'; // $login = '******'; // $password = '******'; // $resultarray = get_163contacts($login, $password); // Zend_Debug::dump($resultarray); // include_once 'yahoo.php'; // $obj = new GrabYahoo(); // $contacts = $obj->getAddressbook('*****@*****.**','19990402'); // Zend_Debug::dump($contacts); // include_once "contacts_fn.php"; // $ret_array = get_msncontacts('*****@*****.**', '1999040211'); // Zend_Debug::dump($ret_array); // $this->_helper->layout->setLayout("layout_admin"); $this->_helper->layout->disableLayout(); // get date from db $db = Zend_Registry::get('db'); $select = $db->select(); $select->from('report', array('left(create_date,10) as date', 'accesscode'))->where('report.campaign_id = 3')->where("report.state = 'APPROVED'")->order('date'); $results = $db->fetchAll($select); $accesscodeDbMatchArray = array(); foreach ($results as $result) { $accesscodeDbMatchArray[$result['accesscode']] = $result['date']; } $accesscodeArray = array_keys($accesscodeDbMatchArray); // Zend_Debug::Dump($accesscodematchArray); // get value from ws $indicate2Connect = new Indicate2_Connect(); $response = $indicate2Connect->getAnswerSetForSurvey(385, null, array(array('ContextIndex' => 1, 'QuestionIndex' => 1), array('ContextIndex' => 1, 'QuestionIndex' => 4)), 0); // Zend_Debug::Dump($response); $talkingdurationArray = array(); $accesscodeResponseMathArray = array(); if (isset($response->AnswerSetType)) { foreach ($response->AnswerSetType as $answerSet) { if (isset($answerSet->AnswerType) && is_array($answerSet->AnswerType) && !empty($answerSet->AnswerType)) { foreach ($answerSet->AnswerType as $answer) { if ($answer->QuestionId == 573) { $accesscodeResponseMathArray[$answerSet->AccessCode] = (int) iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answer->AnswerText))); } if ($answer->QuestionId == 576) { $talkingdurationArray[$answerSet->AccessCode] = (int) iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answer->AnswerText))); } } } else { //get min value, like '11-15' = 11 $accesscodeResponseMathArray[$answerSet->AccessCode] = (int) iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answerSet->AnswerType->AnswerText))); } } } // Zend_Debug::Dump($accesscodeResponseMathArray); // Zend_Debug::Dump($talkingdurationArray); $resultmatchArray = array(); foreach ($accesscodeArray as $accesscode) { $resultmatchArray[$accesscodeDbMatchArray[$accesscode]] = 0; } foreach ($accesscodeArray as $accesscode) { if (array_key_exists($accesscode, $accesscodeResponseMathArray)) { $resultmatchArray[$accesscodeDbMatchArray[$accesscode]] += $accesscodeResponseMathArray[$accesscode]; } } // Zend_Debug::Dump($resultmatchArray); $dateArray = array_keys($resultmatchArray); foreach ($dateArray as $date) { $resultmatchArray[$date] = floor($resultmatchArray[$date] * 1.65); } // Zend_Debug::Dump($resultmatchArray); include 'open-flash-chart.php'; $data_1 = array(); $base = floor(1472 * 1.65); $temp = 0; $resultmatchArray[0] = 0; foreach ($dateArray as $date) { $resultmatchArray[$date] += $resultmatchArray[$temp]; $data_1[] = $resultmatchArray[$date] + $base; $temp = $date; } // Zend_Debug::Dump($data_1); $title = new title("Impressions of BugsLock by day"); $y = new y_axis(); $y->set_range(0, 40000, 10000); $x = new x_axis(); $x_labels = new x_axis_labels(); $x_labels->set_labels($dateArray); $x_labels->set_steps(2); $x_labels->rotate(40); $x->set_labels($x_labels); $line_1_default_dot = new dot(); $line_1_default_dot->colour('#f00000')->tooltip('#x_label#: #val#'); $line_1 = new line(); $line_1->set_default_dot_style($line_1_default_dot); $line_1->set_values($data_1); $line_1->set_width(1); $line_1->set_key('Impression', 10); $this->view->chart = new open_flash_chart(); $this->view->chart->set_title($title); $this->view->chart->add_element($line_1); $this->view->chart->set_y_axis($y); $this->view->chart->set_x_axis($x); $this->view->chart->set_bg_colour('#FFFFFF'); // include 'ofc_sugar.php'; $this->view->chart2 = new open_flash_chart(); $this->view->chart2->set_title(new title('Generation Chart')); $line_1 = new line(); $array_1 = array(); $f = 1.5; for ($i = 0; $i <= 50; $i++) { array_push($array_1, $f); } $line_1->set_values($array_1); // $line_1->set_default_dot_style( new s_hollow_dot('#FBB829', 4) ); $line_1->set_width(1); $line_1->set_colour('#FF0000'); $line_1->set_tooltip("Gen0"); $line_1->set_key('Gen0', 10); $line_1->loop(); $area = new area(); // set the circle line width: $area->set_width(1); // $area->set_default_dot_style( new s_hollow_dot('#45909F', 5) ); $area->set_colour('#FF0000'); // $area->set_fill_colour( '#FF0000' ); // $area->set_fill_alpha( 0.4 ); $area->set_loop(); $area->set_values($array_1); $line_2 = new line(); $array_2 = array(); $f = 2.8; for ($i = 0; $i <= 50; $i++) { array_push($array_2, $f); } $line_2->set_values($array_2); // $line_2->set_default_dot_style( new s_hollow_dot('#FBB829', 4) ); $line_2->set_width(1); $line_2->set_colour('#FBB829'); $line_2->set_tooltip("Gold<br>#val#"); $line_2->set_key('Gen1', 10); $line_2->loop(); $line_4 = new line(); $array_4 = array(); $f = 5; for ($i = 0; $i <= 50; $i++) { array_push($array_4, $f); } $line_4->set_values($array_4); // $line_2->set_default_dot_style( new s_star('#8000FF', 4) ); $line_4->set_width(1); $line_4->set_colour('#3030D0'); $line_4->set_tooltip("Purple<br>#val#"); $line_4->set_key('Gen2', 10); $line_4->loop(); // add the area object to the chart: $this->view->chart2->add_element($line_1); $this->view->chart2->add_element($line_2); $this->view->chart2->add_element($line_4); $r = new radar_axis(5); $r->set_colour('#FFFFFF'); $r->set_grid_colour('#FFFFFF'); $labels = new radar_axis_labels(array('G0', '', 'G1', '', 'G2')); $labels->set_colour('#9F819F'); $r->set_labels($labels); $this->view->chart2->set_radar_axis($r); $tooltip = new tooltip(); $tooltip->set_proximity(); $this->view->chart2->set_tooltip($tooltip); $this->view->chart2->set_bg_colour('#ffffff'); // echo $this->view->chart2->toPrettyString(); }
public function get_jx_json($info, $type = '') { $year = array_keys($info); $price = array_values($info); $chart = new open_flash_chart(); $chart->set_bg_colour('#FFFFFF'); //flash背景颜色 //$title = new title( 'UK Petrol price (pence) per Litre' ); //$title->set_style( "{font-size: 20px; color: #A2ACBA; text-align: center;}" ); //$chart->set_title( $title ); $d = new hollow_dot(); $d->size(3)->halo_size(0)->colour('#8f8fbd'); $area = new area(); $area->set_width(2); $area->set_default_dot_style($d); $area->set_fill_colour('#eaf6ff'); $area->set_fill_alpha(0.4); $area->set_colour('#8f8fbd'); //$area->set_values($price); $area->set_values($price); $chart->add_element($area); $num = intval(count($year >= 7 ? $year : 7) / 7); if ($num == 0) { $num = intval(count($year)); } $num = $num > 0 ? $num : 1; $x_labels = new x_axis_labels(); $x_labels->set_steps($num); $x_labels->set_size(12); $x_labels->set_colour('#000000'); $x_labels->set_labels($year); if (count($year) > 0) { $x_labels->set_vertical(); } // // 插入数据 $x = new x_axis(); $x->set_colour('#000000'); $x->set_grid_colour('#dadada'); $x->set_offset(false); $x->set_steps($num); // Add the X Axis Labels to the X Axis //$x->set_labels($x_labels); $x->set_labels_from_array($year); $chart->set_x_axis($x); $y = new y_axis(); $y->labels = null; $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; }
$ok = mysql_query($stmt); if ($ok) { while ($row = mysql_fetch_object($ok)) { $data_w[$row->m] = round((double) $row->Watt, 3); $data_t[$row->m] = round((double) $row->ETotal, 3); } $title = new title("\nJahresueberblick Verteilung"); $title->set_style('{font-size: 20px; color: #778877}'); $vals = array(); for ($i = 0; $i < count($data_w); $i++) { $tmp = new solid_dot($data_t[$i]); $tmp->colour('#4d4d4d')->tooltip("{$time_axis[$i]}<br>#val# kWh"); $vals[] = $tmp; } $area_w = new area(); $area_w->set_width(1); $area_w->set_default_dot_style(new hollow_dot('#EFC01D', 5)); $area_w->set_colour('#EFC01D'); $area_w->set_fill_colour('#EFC01D'); $area_w->set_fill_alpha(0.4); $area_w->set_loop(); $area_w->set_values($vals); $line_t = new line(); $line_t->set_values($data_t); $max = max($data_t) * 1.15; $label = array(); for ($i = 0; $i < $max; $i = $i + round($max * 0.1, -1)) { $label[] = $i; } $r = new radar_axis($max); $r->set_colour('#EFD1EF');
//$items[] = new ofc_menu_item('Save... ','save_image'); $m->values($items); $chart->set_menu($m); */ //var_dump($y_data); $hol = new hollow_dot(); $hol->size(3)->halo_size(1)->tooltip('#key# <br>Listeners: #val#<br>Time: #x_label#'); //foreach //var_dump($y_data); foreach ($y_data as $key => $data) { $line_dot = new area(); //$line_dot = new line(); if (isset($channels[$key])) { $legend = $channels[$key]['name'] . ':(' . end($data) . ')'; $color = $channels[$key]['color']; $line_dot->set_width(1); } else { $legend = 'Total:(' . end($data) . "/{$total_avg}/{$total_max})"; $color = '#e81dd7'; $line_dot->set_width(3); } $line_dot->set_values($data); $line_dot->set_default_dot_style($hol); $line_dot->set_fill_colour($color); $line_dot->set_fill_alpha(0.05); $line_dot->set_colour($color); $line_dot->set_key($legend, 10); $chart->add_element($line_dot); $line_dot = NULL; } $y = new y_axis();
function get_linear_graph($dates, $vals, $keys = array()) { include 'php-ofc-library/open-flash-chart.php'; $max_y = 0; $arr_filled = array(); for ($i = 0; $i < count($dates); $i++) { $year[] = $dates[$i]; for ($m = 0; $m < count($vals); $m++) { $price[$m][] = (int) $vals[$m][$i]; if ($max_y < (int) $vals[$m][$i]) { $max_y = (int) $vals[$m][$i]; } if (@$arr_filled[$m] != $vals[$m][$i] and @$arr_filled[$m] == 0) { @($arr_filled[$m] = (int) $vals[$m][$i]); } } } while ($max_y % 10 != 0) { $max_y++; } $chart = new open_flash_chart(); //$title = new title( 'UK Petrol price (pence) per Litre' ); $d = new anchor(); if (count($dates) > 60) { $d->size(2); } else { $d->size(3); } $d->halo_size(1); $d->colour('#3D5C56'); $d->rotation(0); $d->sides(4); for ($i = 0; $i < count($price); $i++) { if ($arr_filled[$i] == 0) { continue; } if ($i == 0) { $color = '#5E0722'; } elseif ($i == 1) { $color = '#00FF00'; } else { $color = '#FF0000'; } $area = new area(); $area->set_colour($color); $area->set_default_dot_style($d); $area->set_values($price[$i]); if (isset($keys[$i])) { $area->set_key($keys[$i], 12); } // mb_convert_encoding($keys[$i], "UTF-8", "Windows-1251") $area->set_width(2); $chart->add_element($area); } $x_labels = new x_axis_labels(); if (count($dates) > 40) { $x_labels->set_steps(7); } else { $x_labels->set_steps(1); } $x_labels->set_vertical(); $x_labels->set_colour('#000000'); $x_labels->set_labels($year); $x_labels->rotate(-55); $x_labels->set_size(12); $x = new x_axis(); $x->set_colour('#000000'); $x->set_grid_colour('#DDDDDD'); //$x->set_offset( false ); $x->set_steps(1); // Add the X Axis Labels to the X Axis $x->set_labels($x_labels); $chart->set_x_axis($x); $y = new y_axis(); $y->set_range(0, $max_y); $y->set_colour('#000000'); $y->set_grid_colour('#DDDDDD'); $chart->add_y_axis($y); $chart->set_bg_colour("#FFFFFF"); ?> <script type="text/javascript" src="script/json/json2.js"></script> <script type="text/javascript" src="script/swfobject.js"></script> <script type="text/javascript"> swfobject.embedSWF("open-flash-chart.swf", "my_chart", "600", "350", "9.0.0"); </script> <script type="text/javascript"> function ofc_ready() { } function open_flash_chart_data() { return JSON.stringify(data); } function findSWF(movieName) { if (navigator.appName.indexOf("Microsoft")!= -1) { return window[movieName]; } else { return document[movieName]; } } var data = <?php echo $chart->toPrettyString(); ?> ; </script> <?php }