本文整理汇总了PHP中open_flash_chart::set_y_axis方法的典型用法代码示例。如果您正苦于以下问题:PHP open_flash_chart::set_y_axis方法的具体用法?PHP open_flash_chart::set_y_axis怎么用?PHP open_flash_chart::set_y_axis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类open_flash_chart
的用法示例。
在下文中一共展示了open_flash_chart::set_y_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: title
$title = new title('Jumlah Data Peserta KB Per RT, RW ' . $aRw[$_REQUEST['rwId']]['nama'] . ' Total : ' . $total . ' ( ' . date("D M d Y") . ' ) ');
$title->set_style('{font-size:15px; color: #bcd6ff; margin:0px; background-color: #5E83BF;}');
$bar = new bar_3d();
$bar->set_values($jumlah);
$bar->colour = '#9999FF';
$bar->set_on_show(new bar_on_show('grow-up', 1, 0));
$labels = new x_axis_labels();
$labels->set_labels($rt);
$y_base = new y_axis_base();
$y_base->set_range(0, $maxJumlah + round($maxJumlah / 2), round($maxJumlah / 10));
$x = new x_axis();
$x->set_labels($labels);
$x->set_3d(5);
$y = new y_axis();
$y->set_labels($y_labels);
$tags = new ofc_tags();
$tags->font('Verdana', 10)->colour('#000000')->align_x_center()->text('#y#');
$i = 0;
foreach ($jumlah as $j) {
$tags->append_tag(new ofc_tag($i, $j));
$i++;
}
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($bar);
$chart->add_element($tags);
$chart->set_x_axis($x);
$chart->set_y_axis($y_base);
echo $chart->toString();
?>
示例5: array
function _setChartdata($config)
{
require_once JLG_PATH_SITE . '/assets/classes/open-flash-chart/open-flash-chart.php';
$data = $this->get('ChartData');
// Calculate Values for Chart Object
$forSum = array();
$againstSum = array();
$matchDayGoalsCount = array();
$round_labels = array();
foreach ($data as $rw) {
if (!$rw->homegoalspd) {
$rw->homegoalspd = 0;
}
if (!$rw->guestgoalspd) {
$rw->guestgoalspd = 0;
}
$homeSum[] = (int) $rw->homegoalspd;
$awaySum[] = (int) $rw->guestgoalspd;
// check, if both results are missing and avoid drawing the flatline of "0" goals for not played games yet
if (!$rw->homegoalspd && !$rw->guestgoalspd) {
$matchDayGoalsCount[] = null;
} else {
$matchDayGoalsCount[] = (int) $rw->homegoalspd + $rw->guestgoalspd;
}
$round_labels[] = $rw->roundcode;
}
$chart = new open_flash_chart();
//$chart->set_title( $title );
$chart->set_bg_colour($config['bg_colour']);
if (!empty($homeSum) && !empty($awaySum)) {
if ($config['home_away_stats']) {
$bar1 = new $config['bartype_1']();
$bar1->set_values($homeSum);
$bar1->set_tooltip(JText::_('COM_JOOMLEAGUE_STATS_HOME') . ": #val#");
$bar1->set_colour($config['bar1']);
$bar1->set_on_show(new bar_on_show($config['animation_1'], $config['cascade_1'], $config['delay_1']));
$bar1->set_key(JText::_('COM_JOOMLEAGUE_STATS_HOME'), 12);
$bar2 = new $config['bartype_2']();
$bar2->set_values($awaySum);
$bar2->set_tooltip(JText::_('COM_JOOMLEAGUE_STATS_AWAY') . ": #val#");
$bar2->set_colour($config['bar2']);
$bar2->set_on_show(new bar_on_show($config['animation_2'], $config['cascade_2'], $config['delay_2']));
$bar2->set_key(JText::_('COM_JOOMLEAGUE_STATS_AWAY'), 12);
$chart->add_element($bar1);
$chart->add_element($bar2);
}
}
// total
$d = new $config['dotstyle_3']();
$d->size((int) $config['line3_dot_strength']);
$d->halo_size(1);
$d->colour($config['line3']);
$d->tooltip(JText::_('COM_JOOMLEAGUE_STATS_TOTAL2') . ' #val#');
$line = new line();
$line->set_default_dot_style($d);
$line->set_values($matchDayGoalsCount);
$line->set_width((int) $config['line3_strength']);
$line->set_key(JText::_('COM_JOOMLEAGUE_STATS_TOTAL'), 12);
$line->set_colour($config['line3']);
$line->on_show(new line_on_show($config['l_animation_3'], $config['l_cascade_3'], $config['l_delay_3']));
$chart->add_element($line);
$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_STATS_ROUNDS'));
$x_legend->set_style('{font-size: 15px; color: #778877}');
$chart->set_x_legend($x_legend);
$y = new y_axis();
$y->set_range(0, @max($matchDayGoalsCount) + 2, 1);
$y->set_steps(round(@max($matchDayGoalsCount) / 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_STATS_GOALS'));
$y_legend->set_style('{font-size: 15px; color: #778877}');
$chart->set_y_legend($y_legend);
$this->chartdata = $chart;
}
示例6: 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};
//.........这里部分代码省略.........
示例7: renderHTML
//.........这里部分代码省略.........
if ($cfg_stats_acc_other) {
$val = max($acc_records['other']);
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]);
示例8: 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);
}
示例9: GetRenderContent
//.........这里部分代码省略.........
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();
$aChartLabels = array();
$maxValue = 0;
foreach ($aGroupBy as $iRow => $iCount) {
$oBarValue = new bar_value($iCount);
$oBarValue->on_click("ofc_drill_down_{$sId}");
$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);
}
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);
示例10: array
');
$deposits = array();
$withdrawals = array();
$weeks = array();
while ($row = mysql_fetch_assoc($result)) {
$weeks[] = date('d.m.Y', $row['stamp']);
$deposits[] = round($row['deposits'], 2);
$withdrawals[] = -round($row['withdrawals'], 2);
}
//lines
$line1 = new line();
$line1->set_values($deposits);
$line1->set_colour('#00FF00');
$line2 = new line();
$line2->set_values($withdrawals);
$line2->set_colour('#FF0000');
//axises
$axis_x = new x_axis();
$axis_x_labels = new x_axis_labels();
$axis_x_labels->set_labels($weeks);
$axis_x->set_labels($axis_x_labels);
$axis_y = new y_axis();
$axis_y->range(0, max(max($deposits), max($withdrawals)), 1000);
//chart
$chart = new open_flash_chart();
$chart->set_y_axis($axis_y);
$chart->set_x_axis($axis_x);
$chart->add_element($line1);
$chart->add_element($line2);
$chart->set_bg_colour('#FFFFFF');
echo $chart->toPrettyString();
示例11: 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
);
}
示例12: loadaverage
function loadaverage()
{
sleep(1);
$uptime = trim(shell_exec("cat /proc/uptime |awk '{print \$1}' |cut -d '.' -f 1"));
$load_average_1min = trim(shell_exec("cat /proc/loadavg |awk '{print \$1}'"));
$load_average_5min = trim(shell_exec("cat /proc/loadavg |awk '{print \$2}'"));
$load_average_15min = trim(shell_exec("cat /proc/loadavg |awk '{print \$3}'"));
if ($load_average_1min <= 1) {
$stats = '当前系统空闲';
} elseif ($load_average_1min <= 4) {
$stats = '当前系统正常';
} else {
$stats = '当前系统繁忙';
}
$days = floor($uptime / 86400);
$hours = floor($uptime % 86400 / 3600);
$minutes = floor($uptime % 3600 / 60);
$title = new title("系统平均负载\n{$stats}");
$title->set_style("{font-size: 12px; font-family: Times New Roman; font-weight: bold; color: #A2ACBA; text-align: center;}");
settype($load_average_1min, "float");
settype($load_average_5min, "float");
settype($load_average_15min, "float");
$load_average = array($load_average_1min, $load_average_5min, $load_average_15min);
function colour($value)
{
if ($value <= 1) {
$colour = "#339900";
} elseif ($value <= 4) {
$colour = "#FFFF00";
} else {
$colour = "#FF0033";
}
return $colour;
}
if (max($load_average) <= 0.5) {
$y_axis_max = 0.5;
} elseif (max($load_average) <= 1) {
$y_axis_max = 1;
} elseif (max($load_average) <= 5) {
$y_axis_max = 5;
} elseif (max($load_average) <= 10) {
$y_axis_max = 10;
} elseif (max($load_average) <= 50) {
$y_axis_max = 50;
} else {
$y_axis_max = 100;
}
$y_axis_step = $y_axis_max / 5;
if ($load_average_1min == 0) {
$data[0] = new bar_value($y_axis_max / 100);
$data[0]->set_colour(colour($load_average_1min));
$data[0]->set_tooltip(0);
} else {
$data[0] = new bar_value($load_average_1min);
$data[0]->set_colour(colour($load_average_1min));
$data[0]->set_tooltip('#val#');
}
if ($load_average_5min == 0) {
$data[1] = new bar_value($y_axis_max / 100);
$data[1]->set_colour(colour($load_average_5min));
$data[1]->set_tooltip(0);
} else {
$data[1] = new bar_value($load_average_5min);
$data[1]->set_colour(colour($load_average_5min));
$data[1]->set_tooltip('#val#');
}
if ($load_average_15min == 0) {
$data[2] = new bar_value($y_axis_max / 100);
$data[2]->set_colour(colour($load_average_15min));
$data[2]->set_tooltip(0);
} else {
$data[2] = new bar_value($load_average_15min);
$data[2]->set_colour(colour($load_average_15min));
$data[2]->set_tooltip('#val#');
}
$bar = new bar_glass();
$bar->set_values($data);
$x = new x_axis();
$x->set_labels_from_array(array('1分钟', '5分钟', '15分钟'));
$y = new y_axis();
$y->set_range(0, $y_axis_max, $y_axis_step);
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($bar);
$chart->set_bg_colour('#FFFFFF');
$chart->set_x_axis($x);
$chart->set_y_axis($y);
$x_legend = new x_legend("系统当前已运行 {$days} 天 {$hours} 小时 {$minutes} 分钟");
$x_legend->set_style('{font-size: 12px; color: #778877}');
$chart->set_x_legend($x_legend);
header("Cache-Control: cache, must-revalidate");
header("Pragma: public");
echo $chart->toString();
}
示例13: 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();
}
示例14: 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);
//
//.........这里部分代码省略.........
示例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);
}