Пример #1
0
 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);
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * Method to render a statistical chart using Open Flash library.
  *
  * @return false if someting wrong
  */
 function render()
 {
     $values = array();
     foreach ($this->values as $number_variable => $variable) {
         $values[$number_variable] = (int) $variable;
     }
     $area = new area();
     $area->set_default_dot_style(new hollow_dot());
     $area->set_colour('#5B56B6');
     $area->set_fill_alpha(0.4);
     $area->set_values($values);
     $area->set_key('Values', 12);
     $x_labels = new x_axis_labels();
     $x_labels->set_steps(1);
     $x_labels->set_vertical();
     $x_labels->set_colour('#A2ACBA');
     $x_labels->set_labels($this->legend);
     $x = new x_axis();
     $x->set_colour('#A2ACBA');
     $x->set_grid_colour('#D7E4A3');
     $x->set_offset(false);
     $x->set_steps(1);
     // Add the X Axis Labels to the X Axis
     $x->set_labels($x_labels);
     $y = new y_axis();
     $y_max = max($values) > 0 ? max($values) : 4;
     $y_mod = (int) ($y_max / 4 + 1);
     $y_max += $y_mod - $y_max % $y_mod;
     $y->set_range(0, $y_max, $y_mod);
     $y->labels = null;
     $y->set_offset(false);
     $chart = new open_flash_chart();
     $chart->set_x_axis($x);
     $chart->add_y_axis($y);
     $chart->add_element($area);
     return $chart;
 }
Пример #4
0
$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();
$x_labels->set_steps(4);
$x_labels->set_vertical();
Пример #5
0
$q .= " FROM jng_sp_orders jo";
$q .= " LEFT JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id=jo.jng_sp_orders_id";
$q .= " WHERE jo.jng_sp_id IN (" . implode(',', array_keys($sp_active)) . ") AND jo.order_date>=DATE_SUB(CURRENT_DATE(), INTERVAL {$days} DAY) AND joi.status NOT IN (10,12)";
$q .= ")dt ORDER BY order_date";
$res = tep_db_query($q);
while ($r = tep_db_fetch_array($res)) {
    $p = date($format_date, strtotime($r['order_date']));
    $bar_values[$p] += $r['products'];
}
//Start constructing charts
$title = new title('Last ' . $days . ' Days Sales Chart');
$title->set_style("{font-size:14px; font-weight:bold; padding:10px;}");
$chart = new open_flash_chart();
$chart->set_title($title);
$area = new area();
$area->set_colour('#5B56B6');
$area->set_values(array_values($bar_values));
$area->set_key('Products', 12);
$chart->add_element($area);
//define x-axis
$x_labels = new x_axis_labels();
$x_labels->set_steps(4);
$x_labels->set_labels($period);
$x = new x_axis();
$x->set_grid_colour('#D7E4A3');
//$x->set_offset($period_offset);
$x->set_steps(4);
// Add the X Axis Labels to the X Axis
$x->set_labels($x_labels);
$chart->set_x_axis($x);
//define y-axis
Пример #6
0
 */
 /*
     $line_max = new line();
     $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;
Пример #7
0
 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();
 }
Пример #8
0
$year[] = '2004';
$price[] = 77.90000000000001;
$year[] = '2005';
$price[] = 79.90000000000001;
$year[] = '2006';
$price[] = 88.90000000000001;
$year[] = '2007';
$price[] = 87.90000000000001;
$year[] = '2008';
$price[] = 103.9;
$chart = new open_flash_chart();
$title = new title('UK Petrol price (pence) per Litre');
$title->set_style("{font-size: 20px; color: #A2ACBA; text-align: center;}");
$chart->set_title($title);
$area = new area();
$area->set_colour('#8f8fbd');
$area->set_values($price);
$area->set_key('Price', 12);
$chart->add_element($area);
$x_labels = new x_axis_labels();
$x_labels->set_steps(2);
$x_labels->set_vertical();
$x_labels->set_colour('#A2ACBA');
$x_labels->set_labels($year);
// ²åÈëÊý¾Ý
$x = new x_axis();
$x->set_colour('#dadada');
$x->set_grid_colour('#D7E4A3');
$x->set_offset(false);
$x->set_steps(4);
// Add the X Axis Labels to the X Axis
 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;
 }
Пример #10
0
 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');
 $r->set_steps(round($max * 0.1, -1));
 $r->set_grid_colour('#EFD1EF');
Пример #11
0
    $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();
// grid steps:
$y->set_range(0, $max_val + 10, (int) (($max_val + 10) / 10));
/*$y_labels = new y_axis_labels();
$y_labels->set_size (15);
$y->set_labels( $y_labels );*/
$chart->set_y_axis($y);
$x = new x_axis();
$x->offset(true)->steps(1);
//var_dump($labels);
$chart->set_x_axis($x);
Пример #12
0
 function netio()
 {
     function bit_to_kb($n)
     {
         return round($n / 1000, 2);
     }
     function bit_to_mb($n)
     {
         return round($n / 1000000, 2);
     }
     function get_data()
     {
         $recv_l = trim(shell_exec("cat /sys/class/net/eth0/statistics/rx_bytes")) / 8;
         sleep(1);
         $recv_n = trim(shell_exec("cat /sys/class/net/eth0/statistics/rx_bytes")) / 8;
         return $recv_n - $recv_l;
     }
     if (array_key_exists('netio', $_SESSION) && array_key_exists('recv_l', $_SESSION)) {
         if (count($_SESSION['netio']) == 10) {
             array_shift($_SESSION['netio']);
             $_SESSION['netio'][] = get_data();
         } else {
             $_SESSION['netio'][] = get_data();
             $_SESSION['recv_l'] = end($_SESSION['netio']);
         }
     } else {
         $_SESSION['netio'] = array(0, 0, 0, 0, 0, 0, 0, 0, 0);
         $_SESSION['netio'][] = get_data();
         $_SESSION['recv_l'] = end($_SESSION['netio']);
     }
     $data = $_SESSION['netio'];
     /*
       $data = array();
     
       for($i=0;$i<40;$i++){
       $data[] = rand(1000000,10000000);
       }
     */
     foreach (range(1, 10) as $i) {
         settype($i, 'string');
         $second[] = $i;
     }
     if (max($data) <= 1000) {
         $data = array_map("bit_to_kb", $data);
         $y_axis_max = 1;
         $y_axis_key_text = " KB/s";
     } elseif (max($data) <= 10000) {
         $data = array_map("bit_to_kb", $data);
         $y_axis_max = 10;
         $y_axis_key_text = " KB/s";
     } elseif (max($data) <= 100000) {
         $data = array_map("bit_to_kb", $data);
         $y_axis_max = 100;
         $y_axis_key_text = " KB/s";
     } elseif (max($data) <= 1000000) {
         $data = array_map("bit_to_kb", $data);
         $y_axis_max = 1000;
         $y_axis_key_text = " KB/s";
     } elseif (max($data) <= 10000000) {
         $data = array_map("bit_to_mb", $data);
         $y_axis_max = 10;
         $y_axis_key_text = " MB/s";
     } else {
         $data = array_map("bit_to_mb", $data);
         $y_axis_max = 100;
         $y_axis_key_text = " MB/s";
     }
     $y_axis_step = $y_axis_max / 5;
     $chart = new open_flash_chart();
     $title = new title("实时流量显示");
     $title->set_style("{font-size: 12px; color: #A2ACBA; text-align: center;}");
     $chart->set_title($title);
     #点是指曲线图上的顶点
     #		$d = new dot();
     #		$d->colour('#9C0E57')->size(3);
     $area = new area();
     #width是指曲线的宽度
     #		$area->set_width(3);
     #		$area->set_default_dot_style($d);
     $area->set_colour('#5B56B6');
     #value即曲线顶的值
     $area->set_values($data);
     #左上角的文字
     $area->set_key($y_axis_key_text, 10);
     $area->set_fill_colour('#CCCAAA');
     #设透明度
     $area->set_fill_alpha(0.3);
     #area设置结束,使用add_element方法把area加进来
     $chart->add_element($area);
     $chart->set_bg_colour('#FFFFFF');
     #设置label
     $x_labels = new x_axis_labels();
     $x_labels->set_steps(1);
     $x_labels->set_colour('#A2ACBA');
     $x_labels->set_labels($second);
     #设置X轴
     $x_axis = new x_axis();
     $x_axis->set_colour('#A2ACBA');
     $x_axis->set_grid_colour('#D7E4A3');
     $x_axis->set_offset(false);
     $x_axis->set_steps(1);
     $x_axis->set_labels($x_labels);
     $chart->set_x_axis($x_axis);
     #设置X轴的文件说明,即x_legend
     $legend_text = "当前网络流量 " . end($data) . $y_axis_key_text;
     $x_legend = new x_legend($legend_text);
     $x_legend->set_style('{font-size: 12px; color: #778877}');
     $chart->set_x_legend($x_legend);
     #设置轴
     $y_axis = new y_axis();
     $y_axis->set_range(0, $y_axis_max, $y_axis_step);
     $y_axis->labels = null;
     $y_axis->set_offset(false);
     $chart->add_y_axis($y_axis);
     header("Cache-Control: cache, must-revalidate");
     header("Pragma: public");
     echo $chart->toPrettyString();
 }
    $range_max_value = ceil($range_max_value / $range_diff) * $range_diff;
}
$range_step = round(($range_max_value - $range_min_value) / $range_diff);
if ($range_step % $range_diff > 0) {
    $range_step = ceil($range_step / $range_diff) * $range_diff;
}
$area = new area();
$area->set_colour('#5B56B6');
$area->set_values($vc_total);
$area->set_key('Total VC (EUR)', 12);
$area2 = new area();
$area2->set_colour('#B65B56');
$area2->set_values($total_sold);
$area2->set_key('Total Sold', 12);
$area3 = new area();
$area3->set_colour('#CCCCCC');
$area3->set_values($return_rate);
$area3->set_key('Return Rate (%)', 12);
$price_query = "SELECT jo.order_date, joi.price";
$price_query .= " FROM jng_sp_orders_items joi";
$price_query .= " INNER JOIN jng_sp_orders jo ON jo.jng_sp_orders_id=joi.jng_sp_orders_id AND jo.jng_sp_id={$jng_sp_id}";
$price_query .= " WHERE joi.products_id={$products_id} AND joi.status NOT IN (10,12)";
$price_query .= " ORDER BY jo.order_date";
$price_result = tep_db_query($price_query);
$price_data = array();
while ($row = tep_db_fetch_array($price_result)) {
    $p = date('Ym', strtotime($row['order_date']));
    if (!isset($price_data[$p])) {
        $price_data[$p] = array();
    }
    $price_data[$p][] = $row['price'];
Пример #14
0
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 
}