本文整理汇总了PHP中open_flash_chart::set_x_axis方法的典型用法代码示例。如果您正苦于以下问题:PHP open_flash_chart::set_x_axis方法的具体用法?PHP open_flash_chart::set_x_axis怎么用?PHP open_flash_chart::set_x_axis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类open_flash_chart
的用法示例。
在下文中一共展示了open_flash_chart::set_x_axis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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;
}
示例5: array
function _setRankingChartdata($config)
{
require_once JLG_PATH_SITE . DS . "assets" . DS . "classes" . DS . "open-flash-chart" . DS . "open-flash-chart.php";
//$data = $this->get('RankChartData');
//some example data....fixme!!!
$data_1 = array();
$data_2 = array();
for ($i = 0; $i < 6.2; $i += 0.2) {
$data_1[] = sin($i) * 1.9 + 10;
}
for ($i = 0; $i < 6.2; $i += 0.2) {
$data_2[] = sin($i) * 1.3 + 10;
}
$chart = new open_flash_chart();
//***********
//line 1
$d = new $config['dotstyle_1']();
$d->size((int) $config['line1_dot_strength']);
$d->halo_size(1);
$d->colour($config['line1']);
$d->tooltip('Rank: #val#');
$line = new line();
$line->set_default_dot_style($d);
$line->set_values($data_1);
$line->set_width((int) $config['line1_strength']);
///$line->set_key($team->name, 12);
$line->set_colour($config['line1']);
$line->on_show(new line_on_show($config['l_animation_1'], $config['l_cascade_1'], $config['l_delay_1']));
$chart->add_element($line);
//Line 2
$d = new $config['dotstyle_2']();
$d->size((int) $config['line2_dot_strength']);
$d->halo_size(1);
$d->colour($config['line2']);
$d->tooltip('Rank: #val#');
$line = new line();
$line->set_default_dot_style($d);
$line->set_values($data_2);
$line->set_width((int) $config['line2_strength']);
//$line->set_key($team->name, 12);
$line->set_colour($config['line2']);
$line->on_show(new line_on_show($config['l_animation_2'], $config['l_cascade_2'], $config['l_delay_2']));
$chart->add_element($line);
//X-axis
$x = new x_axis();
$x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
//$x->set_labels_from_array($round_labels);
$chart->set_x_axis($x);
$x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_PRED_USER_ROUNDS'));
$x_legend->set_style('{font-size: 15px; color: #778877}');
$chart->set_x_legend($x_legend);
//Y-axis
$y = new y_axis();
$y->set_range(0, @max($data_1) + 2, 1);
$y->set_steps(round(@max($data_1) / 8));
$y->set_colours($config['y_axis_colour'], $config['y_axis_colour_inner']);
$chart->set_y_axis($y);
$y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_PRED_USER_POINTS'));
$y_legend->set_style('{font-size: 15px; color: #778877}');
$chart->set_y_legend($y_legend);
$this->assignRef('rankingchartdata', $chart);
}
示例6: gsitedata
function gsitedata()
{
$this->autoRender = false;
$solid = $this->Session->read('sol');
$host_id = $this->Session->read('host_id');
$tinterval = 3600;
$host_srch = "";
if (!empty($host_id) && $host_id != 0) {
$host_srch = " AND source_id = " . $host_id;
}
$this->DnsMessage->recursive = -1;
$site_count = $this->DnsMessage->query('SELECT hostname, COUNT(*) FROM dns_messages WHERE sol_id = ' . $solid . $host_srch . ' GROUP BY hostname ORDER BY COUNT(*) DESC LIMIT 50');
//sort($site_count);
$data = array();
$x = array();
$max_resp = 0;
foreach ($site_count as $site) {
$data[] = array((int) $site[0]['COUNT(*)'], 0);
if ($max_resp < (int) $site[0]['COUNT(*)']) {
$max_resp = (int) $site[0]['COUNT(*)'];
}
if (empty($site[0]['hostname'])) {
$x[] = (string) $site['dns_messages']['hostname'];
} else {
$x[] = (string) $site[0]['hostname'];
}
}
// joson data format
$title = new title(__("Host Popularity", true));
$title->set_style("{font-size: 14px; color: #990000; text-align: center; font-weight:bold;}");
$bar = new bar_stack();
$bar->set_colours(array('#e77919', '#577261'));
$bar->set_on_show(new bar_on_show('grow-up', 0, 0.5));
$bar->set_values($data);
$bar->set_tooltip('Host: #x_label#<br>Response #val#<br>');
$tooltip = new tooltip();
$tooltip->set_hover();
$tooltip->set_shadow(false);
$tooltip->set_stroke(5);
$tooltip->set_colour("#6E604F");
$tooltip->set_background_colour("#BDB396");
$data_labels = new x_axis_labels();
$data_labels->rotate(90);
$data_labels->set_labels($x);
$x_axis = new x_axis();
$x_axis->set_labels($data_labels);
$y = new y_axis();
$y->set_range(0, $max_resp * 1.1, (int) ($max_resp / 10));
$chart = new open_flash_chart();
$chart->set_bg_colour('#F9F9F9');
$chart->set_title($title);
$chart->add_element($bar);
$chart->set_x_axis($x_axis);
$chart->set_y_axis($y);
$chart->set_tooltip($tooltip);
// menu'
$m = new ofc_menu("#f0E0ff", "#878787");
$m->values(array(new ofc_menu_item(__('DNS Response', true), 'go_gpage')));
$chart->set_menu($m);
header("Content-Type: text/plain");
echo $chart->toPrettyString();
die;
}
示例7: renderHTML
//.........这里部分代码省略.........
if ($ymax < $val) {
$ymax = $val;
}
}
$val = min($acc_records['invite']);
if ($ymin > $val) {
$ymin = $val;
}
$val = min($acc_records['bye']);
if ($ymin > $val) {
$ymin = $val;
}
if ($cfg_stats_acc_message) {
$val = min($acc_records['message']);
if ($ymin > $val) {
$ymin = $val;
}
}
if ($cfg_stats_acc_other) {
$val = min($acc_records['other']);
if ($ymin > $val) {
$ymin = $val;
}
}
if ($ymax > 10) {
$y = new y_axis();
if ($ymin > 10) {
$y->set_range($ymin - 10, $ymax, (int) (($ymax - $ymin + 10) / 10));
} else {
$y->set_range(0, $ymax, (int) ($ymax / 10));
}
$mtsobj->set_y_axis($y);
}
$mtsobj->set_x_axis($x);
$mtsobj->set_bg_colour("#A0C0B0");
/* sip invites chart */
$ivsobj = new open_flash_chart();
$ctitle = "SIP INVITEs";
$ctitle .= " - From " . date('Y-m-d H:i:s', $time_min);
$ctitle .= " To " . date('Y-m-d H:i:s', $time_max);
$ivsobj->set_title(new title($ctitle));
$ymax = 0;
$ymin = 0xfffffff;
$i = 0;
$line[$i] = new line();
$line[$i]->set_default_dot_style($dot_style);
$line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
$line[$i]->set_key("200", 10);
$line[$i]->set_values($acc_records['invite200']);
$ivsobj->add_element($line[$i]);
$i++;
$line[$i] = new line();
$line[$i]->set_default_dot_style($dot_style);
$line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
$line[$i]->set_key("404", 10);
$line[$i]->set_values($acc_records['invite404']);
$ivsobj->add_element($line[$i]);
$i++;
$line[$i] = new line();
$line[$i]->set_default_dot_style($dot_style);
$line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
$line[$i]->set_key("487", 10);
$line[$i]->set_values($acc_records['invite487']);
$ivsobj->add_element($line[$i]);
$i++;
$line[$i] = new line();
示例8: renderHTML
//.........这里部分代码省略.........
$ul_contacts[5] = $ul_contacts[5] + 1;
}
}
/* 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);
示例9: 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) {
//.........这里部分代码省略.........
示例10: RenderChart
protected function RenderChart($oPage, $sId, $aValues, $sDrillDown = '', $aRows = array())
{
// 1- Compute Open Flash Chart data
//
$aValueKeys = array();
$index = 0;
if (count($aValues) > 0 && $sDrillDown != '') {
$oFilter = DBObjectSearch::FromOQL($sDrillDown);
$sClass = $oFilter->GetClass();
$sOQLClause = str_replace('SELECT ' . $sClass, '', $sDrillDown);
$aSQLColNames = array_keys(current($aRows));
// Read the list of columns from the current (i.e. first) element of the array
$oAppContext = new ApplicationContext();
$sURL = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php?operation=search_oql&search_form=0&oql_class=' . $sClass . '&format=html&' . $oAppContext->GetForLink() . '&oql_clause=';
}
$aURLs = array();
foreach ($aValues as $key => $value) {
// Make sure that values are integers (so that max() will work....)
// and build an array of STRING with the keys (numeric keys are transformed into string by PHP :-(
$aValues[$key] = (int) $value;
$aValueKeys[] = (string) $key;
// Build the custom query for the 'drill down' on each element
if ($sDrillDown != '') {
$sFilter = $sOQLClause;
foreach ($aSQLColNames as $sColName) {
$sFilter = str_replace(':' . $sColName, "'" . addslashes($aRows[$key][$sColName]) . "'", $sFilter);
$aURLs[$index] = $sURL . urlencode($sFilter);
}
}
$index++;
}
$oChart = new open_flash_chart();
if ($this->m_sType == 'bars') {
$oChartElement = new bar_glass();
if (count($aValues) > 0) {
$maxValue = max($aValues);
} else {
$maxValue = 1;
}
$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);
$aBarValues = array();
foreach ($aValues as $iValue) {
$oBarValue = new bar_value($iValue);
$oBarValue->on_click("ofc_drilldown_{$sId}");
$aBarValues[] = $oBarValue;
}
$oChartElement->set_values($aBarValues);
//$oChartElement->set_values(array_values($aValues));
$oXAxis = new x_axis();
$oXLabels = new x_axis_labels();
// set them vertical
$oXLabels->set_vertical();
// set the label text
$oXLabels->set_labels($aValueKeys);
// Add the X Axis Labels to the X Axis
$oXAxis->set_labels($oXLabels);
$oChart->set_x_axis($oXAxis);
} else {
$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'));
$aData = array();
foreach ($aValues as $sValue => $iValue) {
$oPieValue = new pie_value($iValue, $sValue);
//@@ BUG: not passed via ajax !!!
$oPieValue->on_click("ofc_drilldown_{$sId}");
$aData[] = $oPieValue;
}
$oChartElement->set_values($aData);
$oChart->x_axis = null;
}
// Title given in HTML
//$oTitle = new title($this->m_sTitle);
//$oChart->set_title($oTitle);
$oChart->set_bg_colour('#FFFFFF');
$oChart->add_element($oChartElement);
$sData = $oChart->toPrettyString();
$sData = json_encode($sData);
// 2- Declare the Javascript function that will render the chart data\
//
$oPage->add_script(<<<EOF
function ofc_get_data_{$sId}()
{
\treturn {$sData};
//.........这里部分代码省略.........
示例11: 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();
}
示例12: 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
);
}
示例13: render_service_reports
function render_service_reports()
{
$content = "<h1>Service Reports</h1>";
// Start Filter for service type
$allServiceTypes = ServiceType::get_service_types();
# $allServiceTypes = array('all' => 'all');
#$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);
//
//.........这里部分代码省略.........
示例14: siremis_get_chart_data
//.........这里部分代码省略.........
$ymin = $ydata[$i][$k];
}
if ($ydata[$i][$k] > $ymax) {
$ymax = $ydata[$i][$k];
}
}
}
$k = $k + 1;
}
$ofcobj = new open_flash_chart();
$ctitle = $chart->GetTitle();
$rev = 0;
if ($chart->GetOrder() && $chart->GetOrder() == "reverse") {
$rev = 1;
}
$x = new x_axis();
$xstep = (int) ($k / 20);
if ($k % 20 != 0) {
$xstep = $xstep + 1;
}
$x->set_steps($xstep);
if ($xydata[0]->getXYType() == "timestamp") {
if ($rev == 1) {
$time_min = $xdata[$k - 1];
$time_max = $xdata[0];
} else {
$time_min = $xdata[0];
$time_max = $xdata[$k - 1];
}
$ctitle .= " - From " . date('Y-m-d H:i:s', $time_min);
$ctitle .= " To " . date('Y-m-d H:i:s', $time_max);
$time_x_labels = new x_axis_labels();
$time_x_labels->rotate(20);
$chart_lbls = array();
for ($i = 0; $i < $k; $i = $i + 1) {
if ($rev == 0) {
$chart_lbls[] = date('H:i', $xdata[$i]);
} else {
$chart_lbls[] = date('H:i', $xdata[$k - $i - 1]);
}
}
$time_x_labels->visible_steps($xstep);
$time_x_labels->set_labels($chart_lbls);
$x->set_labels($time_x_labels);
} else {
$time_x_labels->visible_steps($xstep);
if ($rev == 1) {
$ctitle .= " - From " . $xdata[$k - 1] . " To " . $xdata[0];
} else {
$ctitle .= " - From " . $xdata[0] . " To " . $xdata[$k - 1];
}
}
$ofcobj->set_title(new title($ctitle));
$dot_style = new dot();
$dot_style->size(3)->halo_size(1);
for ($i = 0; $i < $yn; $i++) {
if ($chart->GetChartType() == "area") {
$line[$i] = new area();
$line[$i]->set_fill_alpha(0.3);
$line[$i]->set_default_dot_style($dot_style);
} else {
if ($chart->GetChartType() == "line_dot") {
$line[$i] = new line_dot();
$line[$i]->set_default_dot_style($dot_style);
} else {
$line[$i] = new line();
$line[$i]->set_default_dot_style($dot_style);
}
}
if ($xydata[$i + 1]->GetXYColor() && $xydata[$i + 1]->GetXYColor() != "") {
$line[$i]->set_colour($xydata[$i + 1]->GetXYColor());
}
if ($xydata[$i + 1]->GetXYTitle() && $xydata[$i + 1]->GetXYTitle() != "") {
$line[$i]->set_key($xydata[$i + 1]->GetXYTitle(), 10);
} else {
$line[$i]->set_key("Key " . $i, 10);
}
if ($rev == 1) {
$line[$i]->set_values(array_reverse($ydata[$i]));
} else {
$line[$i]->set_values($ydata[$i]);
}
$ofcobj->add_element($line[$i]);
}
if ($ymax > 10) {
$y = new y_axis();
if ($ymin > 10) {
$y->set_range($ymin - 10, $ymax, (int) (($ymax - $ymin + 10) / 10));
} else {
$y->set_range(0, $ymax, (int) ($ymax / 10));
}
$ofcobj->set_y_axis($y);
}
$ofcobj->set_x_axis($x);
if ($chart->GetBGColor() && $chart->GetBGColor() != "") {
$ofcobj->set_bg_colour($chart->GetBGColor());
}
// return $ofcobj->toPrettyString();
return $ofcobj->toString();
}
示例15: subscription
function subscription()
{
acymailing::setTitle(JText::_('CHARTS'), 'stats', 'diagram&task=subscription');
$listsClass = acymailing::get('class.list');
$lists = $listsClass->getLists('listid');
$db =& JFactory::getDBO();
$db->setQuery('SELECT min(subdate) as minsubdate, min(unsubdate) as minunsubdate FROM ' . acymailing::table('listsub'));
$dates = $db->loadObject();
$spaces = array();
$intervals = 10;
$dates->maxsubdate = time();
$delay = ($dates->maxsubdate - $dates->minsubdate) / $intervals;
for ($i = 0; $i < $intervals; $i++) {
$spaces[$i] = (int) ($dates->minsubdate + $delay * $i);
}
$spaces[$intervals] = $dates->maxsubdate;
$results = array();
$legendX = array();
for ($i = 0; $i <= $intervals; $i++) {
$legendX[] = acymailing::getDate($spaces[$i]);
$db->setQuery('SELECT count(subid) as total, listid FROM ' . acymailing::table('listsub') . ' WHERE `status` != 2 AND `subdate` < ' . $spaces[$i] . ' AND (`status` = 1 OR `unsubdate`>' . $spaces[$i] . ') GROUP BY listid');
$results[$i] = $db->loadObjectList('listid');
}
$title = new title(JText::_('SUB_HISTORY'));
$title->set_style('font-size:20px; color: #FF8040');
$lines = array();
$maxSub = 0;
foreach ($lists as $listid => $oneList) {
$lines[$listid] = new line_base();
$values = array();
for ($i = 0; $i <= $intervals; $i++) {
$values[] = empty($results[$i][$listid]->total) ? 0 : (int) $results[$i][$listid]->total;
}
$lines[$listid]->set_values($values);
$lines[$listid]->set_text($oneList->name);
$lines[$listid]->set_colour($oneList->color);
$maxSub = max($maxSub, max($values));
}
$x_axis = new x_axis();
$xlabelobject = new x_axis_labels();
$xlabelobject->rotate(-20);
$xlabelobject->set_labels($legendX);
$x_axis->set_labels($xlabelobject);
$y_axis = new y_axis();
$y_axis->range(0, $maxSub, intval($maxSub / 10));
$chart = new open_flash_chart();
$chart->set_x_axis($x_axis);
$chart->set_y_axis($y_axis);
$chart->set_title($title);
foreach ($lines as $oneLine) {
$chart->add_element($oneLine);
}
$this->assignRef('chart', $chart);
}