本文整理汇总了PHP中open_flash_chart::toPrettyString方法的典型用法代码示例。如果您正苦于以下问题:PHP open_flash_chart::toPrettyString方法的具体用法?PHP open_flash_chart::toPrettyString怎么用?PHP open_flash_chart::toPrettyString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类open_flash_chart
的用法示例。
在下文中一共展示了open_flash_chart::toPrettyString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJSON
public function getJSON()
{
if ($this->oChart == false) {
return false;
}
return $this->oChart->toPrettyString();
}
示例2: get_laba_rugi
/**
* Generates data for OFC2 line chart in json format
*
* @return void
*/
public function get_laba_rugi()
{
$this->load->plugin('ofc2');
$this->load->model('jurnal_model');
$model_data = $this->jurnal_model->get_laba_rugi_data();
$bulan_data = array("Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des");
for ($i = date('n') + 1; $i <= 12; $i++) {
$pendapatan_kredit = isset($model_data[$i][date('Y') - 1][4][0]) ? $model_data[$i][date('Y') - 1][4][0] : 0;
$pendapatan_debit = isset($model_data[$i][date('Y') - 1][4][1]) ? $model_data[$i][date('Y') - 1][4][1] : 0;
$beban_kredit = isset($model_data[$i][date('Y') - 1][5][0]) ? $model_data[$i][date('Y') - 1][5][0] : 0;
$beban_debit = isset($model_data[$i][date('Y') - 1][5][1]) ? $model_data[$i][date('Y') - 1][5][1] : 0;
$data[] = $pendapatan_kredit - $pendapatan_debit - ($beban_debit - $beban_kredit);
$thn = date('y') - 1;
$thn = strlen($thn) == 1 ? '0' . $thn : $thn;
$x_data[] = $bulan_data[$i - 1] . "'" . $thn;
}
for ($i = 1; $i <= date('n'); $i++) {
$pendapatan_kredit = isset($model_data[$i][date('Y')][4][0]) ? $model_data[$i][date('Y')][4][0] : 0;
$pendapatan_debit = isset($model_data[$i][date('Y')][4][1]) ? $model_data[$i][date('Y')][4][1] : 0;
$beban_kredit = isset($model_data[$i][date('Y')][5][0]) ? $model_data[$i][date('Y')][5][0] : 0;
$beban_debit = isset($model_data[$i][date('Y')][5][1]) ? $model_data[$i][date('Y')][5][1] : 0;
$data[] = $pendapatan_kredit - $pendapatan_debit - ($beban_debit - $beban_kredit);
$x_data[] = $bulan_data[$i - 1] . "'" . date('y');
}
$max = (int) max($data);
$maxlen = strlen($max);
$up = round($max, -($maxlen - 1));
$min = (int) min($data);
$minlen = strlen($min);
$down = round($min, -($minlen - 1));
$abs_max = (int) max(abs($max), abs($min));
$len = strlen($abs_max);
$round = round($abs_max, -($len - 1));
$step = '1' . substr($round, 1);
$up = $max > $up ? $up + $step : $up;
$down = $min < $down ? $down - $step : $down;
$d = new hollow_dot();
$d->size(4)->halo_size(1)->colour('#668053');
$line = new line();
$line->set_values($data);
$line->set_default_dot_style($d);
$line->set_width(5);
$line->set_colour('#7491a0');
$x_labels = new x_axis_labels();
$x_labels->set_labels($x_data);
$x = new x_axis();
$x->set_labels($x_labels);
$x->set_grid_colour('#bfb8b3');
$y = new y_axis();
$y->set_grid_colour('#bfb8b3');
$y->set_range($down, $up, $step);
$chart = new open_flash_chart();
$chart->add_element($line);
$chart->set_x_axis($x);
$chart->set_y_axis($y);
$chart->set_bg_colour('#FFFFFF');
echo $chart->toPrettyString();
}
示例3: build
function build($options = array())
{
if (empty($options)) {
return false;
}
require_once WWW_ROOT . 'php-ofc-library/open-flash-chart.php';
$chart = new open_flash_chart();
if (isset($options['title']['txt'])) {
$title = new title($options['title']['txt']);
if (isset($options['title']['style'])) {
$title->set_style("{" . $options['title']['style'] . "}");
}
$chart->set_title($title);
}
if (isset($options['chart']['bg'])) {
$chart->set_bg_colour($options['chart']['bg']);
}
if (isset($xOptions['color'])) {
$x->colour($xOptions['color']);
}
if (isset($xOptions['grid_colour'])) {
$x->grid_colour($xOptions['grid_colour']);
}
$col = isset($options['color']) ? $options['color'] : null;
$outlineCol = isset($options['outline_col']) ? $options['outline_col'] : null;
if (isset($options['charts'])) {
foreach ($options['charts'] as $chartOpts) {
$type = isset($chartOpts['type']) ? $chartOpts['type'] : 'bar_filled';
$diagram = new $type($chartOpts['col'], $chartOpts['outline']);
if ($type == 'bar_3d') {
$diagram->colour = $col;
}
$diagram->set_values($chartOpts['values']);
if (isset($chartOpts['key'])) {
$diagram->key($chartOpts['key'], 12);
}
$xAxis = $this->xAxis($options);
if ($xAxis !== null) {
$chart->set_x_axis($xAxis);
}
$yAxis = $this->yAxis($options);
if ($xAxis !== null) {
$chart->set_y_axis($yAxis);
}
if (isset($chartOpts['tooltip'])) {
$diagram->set_tooltip($chartOpts['tooltip']);
}
$chart->add_element($diagram);
}
}
return $chart->toPrettyString();
}
示例4: array
function get_statistic()
{
$this->load->library('OpenFlashChartLib', NULL, 'OFCL');
$data_1 = array();
$data_2 = array();
// generate 7 data points
for ($i = 0; $i <= 7; $i++) {
$x = mktime(0, 0, 0, date("m"), date("d") - $i, date('Y'));
$param['sms_date'] = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $i, date("Y")));
$param['user_id'] = $this->session->userdata('id_user');
$y = $this->Kalkun_model->get_sms_used('date', $param);
$data_1[] = new scatter_value($x, $y);
$data_2[] = $y;
}
$def = new solid_dot();
$def->size(4)->halo_size(0)->colour('#21759B')->tooltip('#date:d M y#<br>#val# SMS');
$line = new scatter_line('#21759B', 3);
$line->set_values($data_1);
$line->set_default_dot_style($def);
$line->set_key("SMS used in last 7 days", 10);
$x = new x_axis();
// grid line and tick every 10
$x->set_range(mktime(0, 0, 0, date("m"), date("d") - 7, date('Y')), mktime(0, 0, 0, date("m"), date("d"), date('Y')));
// show ticks and grid lines for every day:
$x->set_steps(86400);
$labels = new x_axis_labels();
// tell the labels to render the number as a date:
$labels->text('#date:M-d#');
// generate labels for every day
$labels->set_steps(86400);
// only display every other label (every other day)
$labels->visible_steps(1);
$labels->rotate(45);
// finally attach the label definition to the x axis
$x->set_labels($labels);
$y = new y_axis();
if (max($data_2) > 0) {
$max = max($data_2);
} else {
$max = 10;
}
$y->set_range(0, $max, 10);
$chart = new open_flash_chart();
//$chart->set_title( $title );
$chart->add_element($line);
$chart->set_x_axis($x);
$chart->set_y_axis($y);
echo $chart->toPrettyString();
}
示例5: buglevel
/**
* 工作耗时饼猪状图
*@param $id 传入的项目ID
*@examlpe
*/
public function buglevel($id)
{
$Public = A('Index', 'Public');
$App = A('App', 'Public');
Vendor('OpenFlash.open-flash-chart');
//main
$Report = M('Report_table');
$id = intval($id);
$color = array('#99C754', '#54C7C5', '#999999', '#996699', '#009900', '#77C600', '#ff7400', '#FF0000', '#4096ee', '#c79810');
$level = $App->getJson('yanzhongxing', '/Linkage');
$info = $Report->field('level,COUNT(id) as num')->where('pid=' . $id)->group('level')->order('level')->select();
//dump($info);
$title = new title();
$title->set_style("font-size:13px; font-weight:bold;");
$pie = new pie();
$pie->set_alpha(0.8);
$pie->start_angle(35);
$pie->add_animation(new pie_fade());
$pie->add_animation(new pie_bounce(5));
$pie->gradient_fill();
$pie->set_tooltip('数量:#val#条, 占:#percent#');
$pie->set_colours($color);
foreach ($info as $k => $t) {
$obj = new pie_value(intval($t['num']), '');
$name = $Public->searchArr($level, 'id', $t['level']);
$obj->set_label($name . ':' . $t['num'] . '条', $color[$k], 12);
$dis_value[] = $obj;
}
//dump($dis_value);
$pie->set_values($dis_value);
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($pie);
$chart->x_axis = null;
$chart->bg_colour = '#FFFFFF';
echo $chart->toPrettyString();
}
示例6: 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;
}
示例7: report_chart
function report_chart($data)
{
// Chart
//
// This is the MODEL section:
//
include 'open-flash-chart/php-ofc-library/open-flash-chart.php';
$title = new title("Availability Report ");
$pie = new pie();
$pie->set_alpha(0.9);
$pie->radius(90);
//$pie->start_angle(100);
$pie->add_animation(new pie_fade());
$pie->set_tooltip('#label#: #percent#<br>#val# of #total#<br>');
$status_colors = array(ok => '#77CC6D', critical => '#FF0000', warning => '#FFD40F', unknown => '#6D86CC', no_data => '#848484');
$status_name = array(ok => 'Ok', critical => 'Critical', warning => 'Warning', unknown => 'Unknown', no_data => 'No Data');
$col = array();
$d = array();
foreach ($data as $name => $value) {
if ($value > 0) {
$d[] = new pie_value($value * 1, "{$status_name[$name]}");
array_push($col, $status_colors[$name]);
}
}
$pie->set_values($d);
$pie->set_colours($col);
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($pie);
$chart->x_axis = null;
$chart->set_bg_colour('#202020');
$title->set_style("{font-size: 16px; font-family: Times New Roman; font-weight: bold; color: #000; text-align: center;}");
$chart->set_bg_colour('#FFFFFF');
$chart->set_title($title);
// This is the VIEW section:
// Should print this first.
//
$heading = "\n <script type='text/javascript' src='open-flash-chart/js/json/json2.js'></script>\n <script type='text/javascript' src='open-flash-chart/js/swfobject.js'></script>\n <script type='text/javascript'>\n swfobject.embedSWF('open-flash-chart/open-flash-chart.swf', 'my_chart', '300', '300', '9.0.0');\n </script>\n\n <script type='text/javascript'>\n\n function open_flash_chart_data() {\n return JSON.stringify(data);\n }\n\n function findSWF(movieName) {\n if (navigator.appName.indexOf('Microsoft')!= -1) {\n return window[movieName];\n } else {\n return document[movieName];\n }\n }\n \n var data = " . $chart->toPrettyString() . "\n\n </script>\n\n\n <script type=\"text/javascript\">\n \n OFC = {};\n \n OFC.jquery = {\n name: 'jQuery',\n version: function(src) { return \$('#'+ src)[0].get_version() },\n rasterize: function (src, dst) { \$('#'+ dst).replaceWith(OFC.jquery.image(src)) },\n image: function(src) { return \"<img src='data:image/png;base64,\" + \$('#'+src)[0].get_img_binary() + \"' />\"},\n popup: function(src) {\n var img_win = window.open('', 'Charts: Export as Image')\n with(img_win.document) {\n write('<html><head><title>Charts: Export as Image<\\/title><\\/head><body>' + OFC.jquery.image(src) + '<\\/body><\\/html>') }\n // stop the 'loading...' message\n img_win.document.close();\n }\n }\n \n // Using_ an object as namespaces is JS Best Practice. I like the Control.XXX style.\n //if (!Control) {var Control = {}}\n //if (typeof(Control == \"undefined\")) {var Control = {}}\n if (typeof(Control == \"undefined\")) {var Control = {OFC: OFC.jquery}}\n \n \n // By default, right-clicking on OFC and choosing \"save image locally\" calls this function.\n // You are free to change the code in OFC and call my wrapper (Control.OFC.your_favorite_save_method)\n // function save_image() { alert(1); Control.OFC.popup('my_chart') }\n function save_image() { alert(\"Your image will be displayed in a new window\"); OFC.jquery.popup('my_chart') }\n </script>\n <div id='my_chart' style='float:left; margin-left:28px;'></div>\n ";
return $heading;
}
示例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: 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();
}
示例10: mailingPieChart
/**
* public static function to generate two pie charts for the mailing reports
* It was extracted because there are two graph in mailing for each mailing and general mailing which is the total
*
* @param array $results data needed for graph values
*/
public static function mailingPieChart($results)
{
$data = array();
//First Pie, Pie Chart for HTML/TEXT format
$valuesFormat = array();
$pieHtmlValues = new pie_value((int) $results['html_sent'], _JNEWS_GRAPH_LBL_HTML);
$pieTextValues = new pie_value((int) $results['text_sent'], _JNEWS_GRAPH_LBL_TEXT);
$valuesFormat[] = $pieHtmlValues;
$valuesFormat[] = $pieTextValues;
if (empty($results['html_sent']) && empty($results['text_sent'])) {
$data['pie1'] = 'empty';
} else {
$css = '{font-size:15px;font-weight:bold;color:#0B55C4;}';
$title = new title(_JNEWS_GRAPH_TITLE_FORMAT);
//Name of the newsletter
$title->set_style($css);
$pieMailing = new pie();
$pieMailing->set_alpha(0.6);
$pieMailing->set_start_angle(35);
$pieMailing->add_animation(new pie_fade());
$pieMailing->set_tooltip('#val#<br>#percent# of 100%');
$pieMailing->set_colours(array('#156cbd', '#368d03', '#f7941d', '#ed145a', '#92278f', '#156cbd', '#182972', '#3e5d2b', '#db4b19', '#9d0039', '#440e62'));
$pieMailing->set_values($valuesFormat);
$chartPie = new open_flash_chart();
$chartPie->set_title($title);
$chartPie->add_element($pieMailing);
$chartPie->set_bg_colour('#FFFFFF');
$data['pie1'] = $chartPie->toPrettyString();
}
//Second chart, Pie chart for the status of mailing process
$valuesProcess = array();
//$pieFailedlValues = new pie_value((int)$results['failed'], _JNEWS_MAILING_FAILED);
//$pieBounceValues = new pie_value((int)$results['bounces'], _JNEWS_MAILING_BOUNCES);
$piePendingValues = new pie_value((int) $results['pending'], _JNEWS_MAILING_PENDING);
$pieSentValues = new pie_value((int) $results['sent'], _JNEWS_MAILING_SENT);
//$valuesProcess[] = $pieFailedlValues;
//$valuesProcess[] = $pieBounceValues;
$valuesProcess[] = $piePendingValues;
$valuesProcess[] = $pieSentValues;
//if(!empty($results['failed']) && !empty($results['pending']) && !empty($results['bounces'])){
if (!empty($results['sent']) || !empty($results['pending'])) {
$css = '{font-size:15px;font-weight:bold;color:#0B55C4;}';
$title = new title(_JNEWS_GRAPH_PIE_TITLE_MAIL);
//Name of the newsletter
$title->set_style($css);
$pieMailing = new pie();
$pieMailing->set_alpha(0.6);
$pieMailing->set_start_angle(35);
$pieMailing->add_animation(new pie_fade());
$pieMailing->set_tooltip('#val#<br>#percent# of 100%');
$pieMailing->set_colours(array('#156cbd', '#368d03', '#f7941d', '#ed145a', '#92278f', '#156cbd', '#182972', '#3e5d2b', '#db4b19', '#9d0039', '#440e62'));
$pieMailing->set_values($valuesProcess);
$chartPie = new open_flash_chart();
$chartPie->set_title($title);
$chartPie->add_element($pieMailing);
$chartPie->set_bg_colour('#FFFFFF');
$data['pie2'] = $chartPie->toPrettyString();
} else {
$data['pie2'] = 'empty';
}
return $data;
}
示例11: array
function _render_statistic($x = array(), $yout = array(), $yin = array(), $type = 'bar', $points)
{
$this->load->helper('date');
$this->load->library('OpenFlashChartLib', NULL, 'OFCL');
$data_1 = array();
$data_2 = array();
$data_3 = array();
switch ($type) {
case 'bar':
for ($i = 0; $i <= $points; $i++) {
$data_1[$i] = $x[$i];
$data_2[$i] = (int) $yout[$i];
// force to integer
$data_3[$i] = (int) $yin[$i];
// force to integer
}
$data_1 = array_reverse($data_1);
$data_2 = array_reverse($data_2);
$data_3 = array_reverse($data_3);
$bar_1 = new bar();
$bar_1->set_values($data_3);
$bar_1->set_colour('#639F45');
$bar_1->key(lang('kalkun_incoming_sms'), 10);
$bar_1->set_tooltip('#x_label#<br>#val# SMS');
//$bar_1->set_key("SMS used in last 7 days", 10);
$bar_2 = new bar();
$bar_2->set_values($data_2);
$bar_2->set_colour('#21759B');
$bar_2->key(lang('kalkun_outgoing_sms'), 10);
$bar_2->set_tooltip('#x_label#<br>#val# SMS');
$x = new x_axis();
$labels = new x_axis_labels();
$labels->set_labels($data_1);
$labels->set_steps(1);
$x->set_labels($labels);
$y = new y_axis();
$max = max(max($data_2), max($data_3));
if ($max < 10) {
$max = 10;
}
$max = ceil($max / 5) * 5;
$range = ceil($max / 5);
$range = ceil($range / 10) * 10;
$y->set_range(0, $max, $range);
$element1 = $bar_1;
$element2 = $bar_2;
break;
case 'line':
for ($i = 0; $i <= 7; $i++) {
$data_1[$i] = new scatter_value($x[$i], $yin[$i]);
$data_2[$i] = new scatter_value($x[$i], $yout[$i]);
$data_3[$i] = (int) $yin[$i];
$data_4[$i] = (int) $yout[$i];
}
$def = new solid_dot();
$def->size(4)->halo_size(0)->colour('#21759B')->tooltip('#date:d M y#<br>#val# SMS');
$line_1 = new scatter_line('#639F45', 3);
$line_1->set_values($data_1);
$line_1->set_default_dot_style($def);
$line_1->set_key("Incoming SMS", 10);
$line_2 = new scatter_line('#21759B', 3);
$line_2->set_values($data_2);
$line_2->set_default_dot_style($def);
$line_2->set_key("Outgoing SMS", 10);
$x = new x_axis();
// grid line and tick every 10
$x->set_range(mktime(0, 0, 0, date("m"), date("d") - 7, date('Y')), mktime(0, 0, 0, date("m"), date("d"), date('Y')));
// show ticks and grid lines for every day:
$x->set_steps(86400);
$labels = new x_axis_labels();
// tell the labels to render the number as a date:
$labels->text('#date:M-d#');
// generate labels for every day
$labels->set_steps(86400);
// only display every other label (every other day)
$labels->visible_steps(1);
$labels->rotate(45);
// finally attach the label definition to the x axis
$x->set_labels($labels);
$y = new y_axis();
$max = max(max($data_3), max($data_4));
if ($max < 1) {
$max = 10;
}
$y->set_range(0, $max, round($max / 100) * 10);
$element1 = $line_1;
$element2 = $line_2;
break;
}
$chart = new open_flash_chart();
$chart->add_element($element1);
$chart->add_element($element2);
$chart->set_x_axis($x);
$chart->set_y_axis($y);
echo $chart->toPrettyString();
}
示例12: GetRenderContent
//.........这里部分代码省略.........
if ($iCount > $maxValue) {
$maxValue = $iCount;
}
$aChartLabels[] = html_entity_decode($aLabels[$iRow], ENT_QUOTES, 'UTF-8');
}
$oYAxis = new y_axis();
$aMagicValues = array(1, 2, 5, 10);
$iMultiplier = 1;
$index = 0;
$iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
while ($maxValue > $iTop) {
$index++;
$iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
if ($index % count($aMagicValues) == 0) {
$iMultiplier = $iMultiplier * 10;
}
}
//echo "oYAxis->set_range(0, $iTop, $iMultiplier);\n";
$oYAxis->set_range(0, $iTop, $iMultiplier);
$oChart->set_y_axis($oYAxis);
$oChartElement->set_values($aData);
$oXAxis = new x_axis();
$oXLabels = new x_axis_labels();
// set them vertical
$oXLabels->set_vertical();
// set the label text
$oXLabels->set_labels($aChartLabels);
// Add the X Axis Labels to the X Axis
$oXAxis->set_labels($oXLabels);
$oChart->set_x_axis($oXAxis);
}
break;
case 'pie':
default:
$oChartElement = new pie();
$oChartElement->set_start_angle(35);
$oChartElement->set_animate(true);
$oChartElement->set_tooltip('#label# - #val# (#percent#)');
$oChartElement->set_colours(array('#FF8A00', '#909980', '#2C2B33', '#CCC08D', '#596664'));
if (isset($aExtraParams['group_by'])) {
if (isset($aExtraParams['group_by_label'])) {
$oGroupByExp = Expression::FromOQL($aExtraParams['group_by']);
$sGroupByLabel = $aExtraParams['group_by_label'];
} else {
// Backward compatibility: group_by is simply a field id
$sAlias = $this->m_oFilter->GetClassAlias();
$oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias);
$sGroupByLabel = MetaModel::GetLabel($this->m_oFilter->GetClass(), $aExtraParams['group_by']);
}
$aGroupBy = array();
$aGroupBy['grouped_by_1'] = $oGroupByExp;
$sSql = $this->m_oFilter->MakeGroupByQuery($aQueryParams, $aGroupBy, true);
$aRes = CMDBSource::QueryToArray($sSql);
$aGroupBy = array();
$aLabels = array();
$iTotalCount = 0;
foreach ($aRes as $iRow => $aRow) {
$sValue = $aRow['grouped_by_1'];
$sHtmlValue = $oGroupByExp->MakeValueLabel($this->m_oFilter, $sValue, $sValue);
$aLabels[$iRow] = strip_tags($sHtmlValue);
$aGroupBy[$iRow] = (int) $aRow['_itop_count_'];
$iTotalCount += $aRow['_itop_count_'];
}
$aData = array();
foreach ($aGroupBy as $iRow => $iCount) {
$sFlashLabel = html_entity_decode($aLabels[$iRow], ENT_QUOTES, 'UTF-8');
$PieValue = new pie_value($iCount, $sFlashLabel);
//@@ BUG: not passed via ajax !!!
$PieValue->on_click("ofc_drill_down_{$sId}");
$aData[] = $PieValue;
}
$oChartElement->set_values($aData);
$oChart->x_axis = null;
}
}
if (isset($aExtraParams['chart_title'])) {
// The title has been given in an url, and urlencoded...
// and urlencode transforms utf-8 into something similar to ISO-8859-1
// Example: é (C3A9 becomes %E9)
// As a consequence, json_encode (called within open-flash-chart.php)
// was returning 'null' and the graph was not displayed at all
// To make sure that the graph is displayed AND to get a correct title
// (at least for european characters) let's transform back into utf-8 !
$sTitle = iconv("ISO-8859-1", "UTF-8//IGNORE", $aExtraParams['chart_title']);
// If the title is a dictionnary entry, fetch it
$sTitle = Dict::S($sTitle);
$oTitle = new title($sTitle);
$oChart->set_title($oTitle);
$oTitle->set_style("{font-size: 16px; font-family: Tahoma; font-weight: bold; text-align: center;}");
}
$oChart->set_bg_colour('#FFFFFF');
$oChart->add_element($oChartElement);
$sHtml = $oChart->toPrettyString();
break;
default:
// Unsupported style, do nothing.
$sHtml .= Dict::format('UI:Error:UnsupportedStyleOfBlock', $this->m_sStyle);
}
return $sHtml;
}
示例13: RenderNoData
public function RenderNoData($oPage, $bEditMode = false, $aExtraParams = array())
{
$sTitle = $this->aProperties['title'];
$aDisplayValues = $this->MakeSimulatedData();
require_once APPROOT . '/pages/php-ofc-library/open-flash-chart.php';
$oChart = new open_flash_chart();
$aGroupBy = array();
$aLabels = array();
foreach ($aDisplayValues as $iRow => $aDisplayData) {
$aLabels[$iRow] = $aDisplayData['label'];
$aGroupBy[$iRow] = (int) $aDisplayData['count'];
}
$oChartElement = new bar_glass();
$aData = array();
$aChartLabels = array();
$maxValue = 0;
foreach ($aGroupBy as $iRow => $iCount) {
$oBarValue = new bar_value($iCount);
$aData[] = $oBarValue;
if ($iCount > $maxValue) {
$maxValue = $iCount;
}
$aChartLabels[] = html_entity_decode($aLabels[$iRow], ENT_QUOTES, 'UTF-8');
}
$oYAxis = new y_axis();
$aMagicValues = array(1, 2, 5, 10);
$iMultiplier = 1;
$index = 0;
$iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
while ($maxValue > $iTop) {
$index++;
$iTop = $aMagicValues[$index % count($aMagicValues)] * $iMultiplier;
if ($index % count($aMagicValues) == 0) {
$iMultiplier = $iMultiplier * 10;
}
}
//echo "oYAxis->set_range(0, $iTop, $iMultiplier);\n";
$oYAxis->set_range(0, $iTop, $iMultiplier);
$oChart->set_y_axis($oYAxis);
$oChartElement->set_values($aData);
$oXAxis = new x_axis();
$oXLabels = new x_axis_labels();
// set them vertical
$oXLabels->set_vertical();
// set the label text
$oXLabels->set_labels($aChartLabels);
// Add the X Axis Labels to the X Axis
$oXAxis->set_labels($oXLabels);
$oChart->set_x_axis($oXAxis);
if (!empty($sTitle)) {
// The title has been given in an url, and urlencoded...
// and urlencode transforms utf-8 into something similar to ISO-8859-1
// Example: é (C3A9 becomes %E9)
// As a consequence, json_encode (called within open-flash-chart.php)
// was returning 'null' and the graph was not displayed at all
// To make sure that the graph is displayed AND to get a correct title
// (at least for european characters) let's transform back into utf-8 !
$sTitle = iconv("ISO-8859-1", "UTF-8//IGNORE", $sTitle);
// If the title is a dictionnary entry, fetch it
$sTitle = $this->oModelReflection->DictString($sTitle);
$oTitle = new title($sTitle);
$oChart->set_title($oTitle);
$oTitle->set_style("{font-size: 16px; font-family: Tahoma; font-weight: bold; text-align: center;}");
}
$oChart->set_bg_colour('#FFFFFF');
$oChart->add_element($oChartElement);
$sData = $oChart->toPrettyString();
$sData = json_encode($sData);
$oPage->add_script(<<<EOF
function ofc_get_data_dashlet_{$this->sId}()
{
\treturn {$sData};
}
EOF
);
$oPage->add('<div class="dashlet-content">');
$oPage->add("<div id=\"dashlet_chart_{$this->sId}\">If the chart does not display, <a href=\"http://get.adobe.com/flash/\" target=\"_blank\">install Flash</a></div>\n");
$oPage->add('</div>');
// $oPage->add_script("function ofc_resize(left, width, top, height) { /* do nothing special */ }");
$oPage->add_ready_script(<<<EOF
swfobject.embedSWF(\t"../images/open-flash-chart.swf",
\t"dashlet_chart_{$this->sId}",
\t"100%", "300","9.0.0",
\t"expressInstall.swf",
\t{"get-data":"ofc_get_data_dashlet_{$this->sId}", "id":"dashlet_chart_{$this->sId}"},
\t{'wmode': 'transparent'}
);
EOF
);
}
示例14: 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();
}
示例15: render_service_reports
//.........这里部分代码省略.........
#$allServiceTypes = array_merge($allServiceTypes, ServiceType::get_service_types());
$allServiceTypes['all'] = 'all';
$service_type = $_GET['service_type'];
$service_filter = $_GET['service_type'];
if ($service_type == '' || !isset($service_type) || !is_numeric($service_type)) {
$service_type = 'all';
$service_filter = '';
}
$filter = "\r\n\t\t<FORM>\r\n\t\t<DIV style=\" \">\r\n\t\t<SELECT name'=service_type_report'\r\n\t\t\tonChange=\"window.location='services.php?&action=serviceReports&service_type='+this.options[this.selectedIndex].value;\">";
foreach ($allServiceTypes as $id => $name) {
if ($service_type == $id) {
$selected = "SELECTED";
} else {
$selected = '';
}
$filter .= "<OPTION value='{$id}' {$selected}>{$name}\n";
}
$filter .= "\r\n\t\t</SELECT>\r\n\t\t</DIV>\r\n\t\t</FORM>\r\n\t";
// End filter
$max_date = strtotime("2009-01-01");
$start_date = date("Y-m") . "-01";
// Get all months since start
$workdate = strtotime($start_date);
$now = strtotime("Now");
$form = new Form(auto, 3);
$headings = array("Period", "In production", "Out of Production");
$data = array();
$x_ax_data = array();
$y_ax_data = array();
$handlers = array();
while ($workdate > $max_date) {
$sql_enddate = date("Y-m-d", $workdate);
$month_period = date("m-Y", $workdate);
// This is for the chart
$month_label = date("M\nY", $workdate);
$graph_date = strtotime("-1 month", $workdate);
$month_label = date("M\nY", $graph_date);
$sql_startdate = date("Y-m-d", $workdate);
array_push($x_ax_data, $month_label);
array_push($y_ax_data, count(Service::get_inprod_services_at_date($sql_startdate, $service_filter)));
// Add one month
$workdate = strtotime("-1 month", $workdate);
$sql_startdate = date("Y-m-d", $workdate);
$out_of_prod = count(Service::get_outprod_services_diff_date($sql_startdate, $sql_enddate, $service_filter));
$in_prod = count(Service::get_inprod_services_diff_date($sql_startdate, $sql_enddate, $service_filter));
array_push($data, "{$sql_startdate} {$sql_enddate}");
array_push($data, $in_prod);
array_push($data, $out_of_prod);
array_push($handlers, "handleEvent('services.php?action=detailedServiceReports&start_date={$sql_startdate}&end_date={$sql_enddate}&service_type={$service_type}')");
}
$form->setTableWidth("224px");
$form->setData($data);
$form->setEventHandler($handlers);
$form->setHeadings($headings);
$form->setSortable(true);
$content .= "<div style=\"float: left; clear: both; margin-right:28px\">" . $form->showForm() . "</div>";
// Chart
//
// This is the MODEL section:
//
include 'open-flash-chart/php-ofc-library/open-flash-chart.php';
// create an X Axis object
//
$y_ax_data = array_reverse($y_ax_data);
$x_ax_data = array_reverse($x_ax_data);
$x = new x_axis();
$x->set_steps(3);
$x->set_labels_from_array($x_ax_data);
$max = max($y_ax_data);
$y = new y_axis();
$y->set_range(0, $max);
// Bar
$bar = new bar();
$bar->set_values($y_ax_data);
// Bar
// ------- LINE 2 -----
$line_2_default_dot = new dot();
$line_2_default_dot->size(3)->halo_size(1)->colour('#3D5C56');
$line_2 = new line();
$line_2->set_default_dot_style($line_2_default_dot);
$line_2->set_values($y_ax_data);
$line_2->set_width(3);
$line_2->set_colour('#3D5C56');
$chart = new open_flash_chart();
$title = new title("In Production Services over Time");
$title->set_style("{font-size: 10px; font-family: Times New Roman; font-weight: bold; color: #000; text-align: center;}");
$chart->set_bg_colour('#FFFFFF');
$chart->set_title($title);
$chart->add_element($bar);
//$chart->add_element( $line1 );
$chart->add_element($line_2);
$chart->set_x_axis($x);
$chart->set_y_axis($y);
//
// This is the VIEW section:
// Should print this first.
//
$heading = "\r\n\t<script type='text/javascript' src='open-flash-chart/js/json/json2.js'></script>\r\n\t<script type='text/javascript' src='open-flash-chart/js/swfobject.js'></script>\r\n\t<script type='text/javascript'>\r\n\tswfobject.embedSWF('open-flash-chart/open-flash-chart.swf', 'my_chart', '660', '350', '9.0.0');\r\n\t</script>\r\n\r\n\t<script type='text/javascript'>\r\n\r\n\tfunction open_flash_chart_data() {\r\n\t\treturn JSON.stringify(data);\r\n\t}\r\n\r\n\tfunction findSWF(movieName) {\r\n \t\tif (navigator.appName.indexOf('Microsoft')!= -1) {\r\n \t\t\treturn window[movieName];\r\n \t\t} else {\r\n \t\t\treturn document[movieName];\r\n \t\t}\r\n\t}\r\n \r\n\tvar data = " . $chart->toPrettyString() . "\r\n\r\n\t</script>\r\n\r\n\r\n\t<script type=\"text/javascript\">\r\n \r\n\tOFC = {};\r\n \r\n\tOFC.jquery = {\r\n \tname: 'jQuery',\r\n \tversion: function(src) { return \$('#'+ src)[0].get_version() },\r\n \trasterize: function (src, dst) { \$('#'+ dst).replaceWith(OFC.jquery.image(src)) },\r\n \timage: function(src) { return \"<img src='data:image/png;base64,\" + \$('#'+src)[0].get_img_binary() + \"' />\"},\r\n \tpopup: function(src) {\r\n var img_win = window.open('', 'Charts: Export as Image')\r\n with(img_win.document) {\r\n write('<html><head><title>Charts: Export as Image<\\/title><\\/head><body>' + OFC.jquery.image(src) + '<\\/body><\\/html>') }\r\n\t\t// stop the 'loading...' message\r\n\t\timg_win.document.close();\r\n \t}\r\n\t}\r\n \r\n\t// Using_ an object as namespaces is JS Best Practice. I like the Control.XXX style.\r\n\t//if (!Control) {var Control = {}}\r\n\t//if (typeof(Control == \"undefined\")) {var Control = {}}\r\n\tif (typeof(Control == \"undefined\")) {var Control = {OFC: OFC.jquery}}\r\n \r\n \r\n\t// By default, right-clicking on OFC and choosing \"save image locally\" calls this function.\r\n\t// You are free to change the code in OFC and call my wrapper (Control.OFC.your_favorite_save_method)\r\n\t// function save_image() { alert(1); Control.OFC.popup('my_chart') }\r\n\tfunction save_image() { alert(\"Your image will be displayed in a new window\"); OFC.jquery.popup('my_chart') }\r\n\t</script>\r\n\t<div id='my_chart' style='float:left; margin-left:28px;'></div>\r\n\t";
print " {$content}\n \r\n\t\t<div style=''<b>Select Service Type:</b>{$filter} <br></div>\n\r\n\t\t{$heading} ";
}