本文整理汇总了PHP中open_flash_chart::add_y_axis方法的典型用法代码示例。如果您正苦于以下问题:PHP open_flash_chart::add_y_axis方法的具体用法?PHP open_flash_chart::add_y_axis怎么用?PHP open_flash_chart::add_y_axis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类open_flash_chart
的用法示例。
在下文中一共展示了open_flash_chart::add_y_axis方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* 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;
}
示例2: title
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();
// Add the X Axis Labels to the X Axis
$x_axis->set_labels($x_labels);
$chart->add_y_axis($y_axis);
$chart->x_axis = $x_axis;
echo $chart->toPrettyString();
示例3: title
$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;
$range_max_value = max($bar_values);
$y_data_step = ceil($range_max_value / $y_points);
$y_data_step = $y_data_step - $y_data_step % 100;
$range_max_value = ceil($range_max_value / $y_data_step) * $y_data_step;
$y->set_range($range_min_value, $range_max_value, $y_data_step);
$chart->add_y_axis($y);
echo $chart->toPrettyString();
require_once 'confy_close.php';
示例4: renderHTML
//.........这里部分代码省略.........
}
}
/* user agents chart */
$ua_title = new title('User Agents');
$ua_x_labels = new x_axis_labels();
$ua_x_labels->rotate(20);
$ua_bar = new bar_glass();
$chart_vals = array();
$chart_lbls = array();
$i = 0;
$ymax = 10;
foreach ($ul_uas as $key => $val) {
if ($val > 0) {
$chart_vals[$i] = new bar_value($val);
$chart_vals[$i]->set_colour($chart_colors[$i % $chart_colors_size]);
$chart_vals[$i]->set_tooltip($key . '<br>#val#');
$chart_lbls[$i] = $key;
if ($ymax < $val) {
$ymax = $val;
}
$i = $i + 1;
}
}
$ua_bar->set_values($chart_vals);
$ua_x_labels->set_labels($chart_lbls);
$x = new x_axis();
$x->set_labels($ua_x_labels);
$y = new y_axis();
$y->set_range(0, $ymax, $ymax / 10);
$ul_uas_chart = new open_flash_chart();
$ul_uas_chart->set_title($ua_title);
$ul_uas_chart->add_element($ua_bar);
$ul_uas_chart->set_x_axis($x);
$ul_uas_chart->add_y_axis($y);
/* supported SIP Methods chart */
$mt_title = new title('Supported SIP Methods');
$mt_x_labels = new x_axis_labels();
$mt_x_labels->rotate(20);
$mt_bar = new bar_glass();
$chart_vals = array();
$chart_lbls = array();
$i = 0;
$ymax = 10;
foreach ($ul_methods as $key => $val) {
if ($val > 0) {
$chart_vals[$i] = new bar_value($val);
$chart_vals[$i]->set_colour($chart_colors[$i % $chart_colors_size]);
$chart_vals[$i]->set_tooltip($key . '<br>#val#');
$chart_lbls[$i] = $key;
if ($ymax < $val) {
$ymax = $val;
}
$i = $i + 1;
}
}
$mt_bar->set_values($chart_vals);
$mt_x_labels->set_labels($chart_lbls);
$x = new x_axis();
$x->set_labels($mt_x_labels);
$y = new y_axis();
$y->set_range(0, $ymax, $ymax / 10);
$mt_chart = new open_flash_chart();
$mt_chart->set_title($mt_title);
$mt_chart->add_element($mt_bar);
$mt_chart->set_x_axis($x);
$mt_chart->add_y_axis($y);
示例5: array
/**
* Build The 3-D Bar Gharph.
*
* @param array $params assoc array of name/value pairs
*
* @return object $chart object of open flash chart.
* @static
*/
static function &bar_3dChart(&$params)
{
$chart = null;
if (empty($params)) {
return $chart;
}
// $params['values'] should contains the values for each
// criteria defined in $params['criteria']
$values = CRM_Utils_Array::value('values', $params);
$criterias = CRM_Utils_Array::value('criteria', $params);
if (!is_array($values) || empty($values) || !is_array($criterias) || empty($criterias)) {
return $chart;
}
// get the required data.
$xReferences = $xValueLabels = $xValues = $yValues = array();
foreach ($values as $xVal => $yVal) {
if (!is_array($yVal) || empty($yVal)) {
continue;
}
$xValueLabels[] = (string) $xVal;
foreach ($criterias as $criteria) {
$xReferences[$criteria][$xVal] = (double) CRM_Utils_Array::value($criteria, $yVal, 0);
$yValues[] = (double) CRM_Utils_Array::value($criteria, $yVal, 0);
}
}
if (empty($xReferences)) {
return $chart;
}
// get the currency.
require_once 'CRM/Utils/Money.php';
$config = CRM_Core_Config::singleton();
$symbol = $config->defaultCurrencySymbol;
// set the tooltip.
$tooltip = CRM_Utils_Array::value('tip', $params, "{$symbol} #val#");
$count = 0;
foreach ($xReferences as $criteria => $values) {
$toolTipVal = $tooltip;
// for seperate tooltip for each criteria
if (is_array($tooltip)) {
$toolTipVal = CRM_Utils_Array::value($criteria, $tooltip, "{$symbol} #val#");
}
// create bar_3d object
$xValues[$count] = new bar_3d();
// set colour pattel
$xValues[$count]->set_colour(self::$_colours[$count]);
// define colur pattel with bar criterias
$xValues[$count]->key((string) $criteria, 12);
// define bar chart values
$xValues[$count]->set_values(array_values($values));
// set tooltip
$xValues[$count]->set_tooltip($toolTipVal);
$count++;
}
$chartTitle = CRM_Utils_Array::value('legend', $params) ? $params['legend'] : ts('Bar Chart');
//set y axis parameters.
$yMin = 0;
// calculate max scale for graph.
$yMax = ceil(max($yValues));
if ($mod = $yMax % str_pad(5, strlen($yMax) - 1, 0)) {
$yMax += str_pad(5, strlen($yMax) - 1, 0) - $mod;
}
// if max value of y-axis <= 0, then set default values
if ($yMax <= 0) {
$ySteps = 1;
$yMax = 5;
} else {
$ySteps = $yMax / 5;
}
// create x axis label obj.
$xLabels = new x_axis_labels();
$xLabels->set_labels($xValueLabels);
// set angle for labels.
if ($xLabelAngle = CRM_Utils_Array::value('xLabelAngle', $params)) {
$xLabels->rotate($xLabelAngle);
}
// create x axis obj.
$xAxis = new x_axis();
$xAxis->set_labels($xLabels);
//create y axis and set range.
$yAxis = new y_axis();
$yAxis->set_range($yMin, $yMax, $ySteps);
// create chart title obj.
$title = new title($chartTitle);
// create chart.
$chart = new open_flash_chart();
// add x axis w/ labels to chart.
$chart->set_x_axis($xAxis);
// add y axis values to chart.
$chart->add_y_axis($yAxis);
// set title to chart.
$chart->set_title($title);
foreach ($xValues as $bar) {
//.........这里部分代码省略.........
示例6: flowview_viewchart
/** 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();
//.........这里部分代码省略.........
示例7: get_jx_json_bar
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;
}
示例8: result_screen
//.........这里部分代码省略.........
$sql_table = 'polls';
$sql_field = 'added';
$page_detail = "Showing the number of Polls added. (Note: All times based on GMT)";
} else {
if ($mode == 'rqst') {
$table = 'Request Statistics';
$sql_table = 'requests';
$sql_field = 'added';
$page_detail = "Showing the number of Requests made. (Note: All times based on GMT)";
}
}
}
}
}
}
}
}
}
}
switch ($_POST['timescale']) {
case 'daily':
$sql_date = "%w %U %m %Y";
$php_date = "F jS - Y";
// $sql_scale = "DAY";
break;
case 'monthly':
$sql_date = "%m %Y";
$php_date = "F Y";
// $sql_scale = "MONTH";
break;
default:
// weekly
$sql_date = "%U %Y";
$php_date = " [F Y]";
// $sql_scale = "WEEK";
break;
}
$sortby = isset($_POST['sortby']) ? mysql_real_escape_string($_POST['sortby']) : "";
// $sortby = sqlesc($sortby);
$sqlq = "SELECT UNIX_TIMESTAMP(MAX({$sql_field})) as result_maxdate,\n\t\t\t\t COUNT(*) as result_count,\n\t\t\t\t DATE_FORMAT({$sql_field},'{$sql_date}') AS result_time\n\t\t\t\t FROM {$sql_table}\n\t\t\t\t WHERE UNIX_TIMESTAMP({$sql_field}) > '{$from_time}'\n\t\t\t\t AND UNIX_TIMESTAMP({$sql_field}) < '{$to_time}'\n\t\t\t\t GROUP BY result_time\n\t\t\t\t ORDER BY {$sql_field} {$sortby}";
$res = @mysql_query($sqlq);
$running_total = 0;
$max_result = 0;
$results = array();
if (mysql_num_rows($res)) {
while ($row = mysql_fetch_assoc($res)) {
if ($row['result_count'] > $max_result) {
$max_result = $row['result_count'];
}
$running_total += $row['result_count'];
$results[] = array('result_maxdate' => $row['result_maxdate'], 'result_count' => $row['result_count'], 'result_time' => $row['result_time']);
}
include 'chart/php-ofc-library/open-flash-chart.php';
foreach ($results as $pOOp => $data) {
$counts[] = (int) $data['result_count'];
if ($_POST['timescale'] == 'weekly') {
$labes[] = "Week #" . strftime("%W", $data['result_maxdate']) . "\n" . date($php_date, $data['result_maxdate']);
} else {
$labes[] = date($php_date, $data['result_maxdate']);
}
}
$title = new title($page_title . "\n" . ucfirst($_POST['timescale']) . " " . $table . " " . $human_from_date['mday'] . " " . $month_names[$human_from_date['mon']] . " " . $human_from_date['year'] . " to " . $human_to_date['mday'] . " " . $month_names[$human_to_date['mon']] . " " . $human_to_date['year']);
$chart = new open_flash_chart();
$chart->set_title($title);
$line_1 = new line_hollow();
$line_1->set_values($counts);
$line_1->set_key($table . " | Total: " . $running_total, 12);
$line_1->set_halo_size(1);
$line_1->set_width(2);
$line_1->set_colour('#0099FF');
$line_1->set_dot_size(5);
$chart->add_element($line_1);
$x_labels = new x_axis_labels();
$x_labels->set_steps(2);
$x_labels->set_vertical();
$x_labels->set_colour('#000000');
$x_labels->set_size(12);
$x_labels->set_labels($labes);
$x = new x_axis();
$x->set_colours('#A2ACBA', '#ECFFAF');
$x->set_steps(2);
$x->set_labels($x_labels);
$chart->set_x_axis($x);
$y = new y_axis();
$y->set_steps(2);
$y->set_colour('#A2ACBA');
$y->set_range(0, max($counts) + 5, 50);
$chart->add_y_axis($y);
$cont = $chart->toPrettyString();
// toFile($_SERVER["DOCUMENT_ROOT"]."/chart/","chart.json",$cont,false);
// unset($cont);
$html = "<script type=\"text/javascript\" src=\"chart/js/json/json2.js\"></script>";
$html .= "<script type=\"text/javascript\" src=\"chart/js/swfobject.js\"></script>";
$html .= "<script type=\"text/javascript\">\n\n\t\t\t\tfunction open_flash_chart_data()\n\t\t\t\t{\n\t\t\t\treturn JSON.stringify(data);\n\t\t\t\t}\n\n\t\t\t\tfunction findSWF(movieName) {\n\t\t\t\t if (navigator.appName.indexOf(\"Microsoft\")!= -1) {\n\t\t\t\t\treturn window[movieName];\n\t\t\t\t } else {\n\t\t\t\t\treturn document[movieName];\n\t\t\t\t }\n\t\t\t\t}\n\n\t\t\t\tvar data = " . $cont . ";\n\n\t\t\t\t\t swfobject.embedSWF(\"chart/open-flash-chart.swf\", \"my_chart\", \"800\", \"" . (max($counts) * 5 < 200 ? "250" : (max($counts) * 5 > 400 ? "400" : max($counts) * 5)) . "\", \"9.0.0\", \"expressInstall.swf\", {\"loading\":\"Please wait while the stats are loaded!\"} );\n\t\t\t\t\t </script>";
$html .= "<div id=\"my_chart\"></div>";
} else {
$html .= "No results found\n";
}
print $html . "<br />";
}
示例9: netio
//.........这里部分代码省略.........
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();
}
示例10: stacked_bar_chart
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();
}
示例11: generateStats
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);
//.........这里部分代码省略.........
示例12: array
/**
* Build The Bar Gharph.
*
* @param array $params assoc array of name/value pairs
*
* @return object $chart object of open flash chart.
* @static
*/
static function &barChart(&$params)
{
$chart = null;
if (empty($params)) {
return $chart;
}
$values = CRM_Utils_Array::value('values', $params);
if (!is_array($values) || empty($values)) {
return $chart;
}
// get the required data.
$xValues = $yValues = array();
foreach ($values as $xVal => $yVal) {
$yValues[] = (double) $yVal;
// we has to have x values as string.
$xValues[] = (string) $xVal;
}
$chartTitle = CRM_Utils_Array::value('legend', $params) ? $params['legend'] : ts('Bar Chart');
//set y axis parameters.
$yMin = 0;
// calculate max scale for graph.
$yMax = max($yValues);
if ($mod = $yMax % str_pad(5, strlen($yMax) - 1, 0)) {
$yMax += str_pad(5, strlen($yMax) - 1, 0) - $mod;
}
$ySteps = $yMax / 5;
// $bar = new bar( );
// glass seem to be more cool
$bar = new bar_glass();
//set values.
$bar->set_values($yValues);
// call user define function to handle on click event.
if ($onClickFunName = CRM_Utils_Array::value('on_click_fun_name', $params)) {
$bar->set_on_click($onClickFunName);
}
// get the currency.
require_once 'CRM/Utils/Money.php';
$config =& CRM_Core_Config::singleton();
$symbol = $config->defaultCurrencySymbol;
// set the tooltip.
$bar->set_tooltip("{$symbol} #val#");
// create x axis label obj.
$xLabels = new x_axis_labels();
$xLabels->set_labels($xValues);
// set angle for labels.
if ($xLabelAngle = CRM_Utils_Array::value('xLabelAngle', $params)) {
$xLabels->rotate($xLabelAngle);
}
// create x axis obj.
$xAxis = new x_axis();
$xAxis->set_labels($xLabels);
//create y axis and set range.
$yAxis = new y_axis();
$yAxis->set_range($yMin, $yMax, $ySteps);
// create chart title obj.
$title = new title($chartTitle);
// create chart.
$chart = new open_flash_chart();
// add x axis w/ labels to chart.
$chart->set_x_axis($xAxis);
// add y axis values to chart.
$chart->add_y_axis($yAxis);
// set title to chart.
$chart->set_title($title);
// add bar element to chart.
$chart->add_element($bar);
// add x axis legend.
if ($xName = CRM_Utils_Array::value('xname', $params)) {
$xLegend = new x_legend($xName);
$xLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
$chart->set_x_legend($xLegend);
}
// add y axis legend.
if ($yName = CRM_Utils_Array::value('yname', $params)) {
$yLegend = new y_legend($yName);
$yLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
$chart->set_y_legend($yLegend);
}
return $chart;
}
示例13: get_linear_graph
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);
}
//.........这里部分代码省略.........