Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
$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
$y = new y_axis();
$range_min_value = 0;
Exemplo n.º 3
0
     $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();
 $x_labels->set_vertical();
Exemplo n.º 4
0
$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
$x->set_labels($x_labels);
$chart->set_x_axis($x);
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
    //$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);
//
Exemplo n.º 7
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_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'];
}
$cat_query = tep_db_query("SELECT price FROM jng_sp_catalog WHERE jng_sp_id={$jng_sp_id} AND products_id={$products_id}");
    }
    if ($a > $range_max_value) {
        $range_max_value = $a;
    }
}
$range_step = round(($range_max_value - $range_min_value) / $period_total);
$chart = new open_flash_chart();
/*
$title = new title('Monthly Total VC');
$title->set_style("{font-size: 20px; color: #A2ACBA; text-align: center;}");
$chart->set_title($title);
*/
$area = new area();
$area->set_colour('#5B56B6');
$area->set_values($amount);
$area->set_key('EUR', 12);
$chart->add_element($area);
$x_labels = new x_axis_labels();
$x_labels->set_steps(1);
$x_labels->set_vertical();
$x_labels->set_colour('#A2ACBA');
$x_labels->set_labels($period_label);
$x = new x_axis();
$x->set_colour('#A2ACBA');
$x->set_grid_colour('#D7E4A3');
$x->set_offset($period_offset);
$x->set_steps(1);
// Add the X Axis Labels to the X Axis
$x->set_labels($x_labels);
$chart->set_x_axis($x);
//
}
$period_total = count($period);
$period_offset = $period_total <= 2;
$period_start = $period[0];
$period_end = $period[$period_total - 1];
$range_diff = 10;
$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;
}
$chart = new open_flash_chart();
$chart->set_bg_colour('#FFFFFF');
$area = new area();
$area->set_colour('#5B56B6');
$area->set_values($amount);
$area->set_key($unit, 12);
$chart->add_element($area);
$x_labels = new x_axis_labels();
$x_labels->set_steps(1);
//$x_labels->set_vertical();
$x_labels->set_labels($period);
$x = new x_axis();
$x->set_grid_colour('#D7E4A3');
$x->set_offset($period_offset);
$x->set_steps(1);
// Add the X Axis Labels to the X Axis
$x->set_labels($x_labels);
$chart->set_x_axis($x);
//
// LOOK:
//
Exemplo n.º 11
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 
}