本文整理汇总了PHP中x_axis_labels::set_vertical方法的典型用法代码示例。如果您正苦于以下问题:PHP x_axis_labels::set_vertical方法的具体用法?PHP x_axis_labels::set_vertical怎么用?PHP x_axis_labels::set_vertical使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类x_axis_labels
的用法示例。
在下文中一共展示了x_axis_labels::set_vertical方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Method to render a statistical chart using Open Flash library.
*
* @return false if someting wrong
*/
function render()
{
$values = array();
foreach ($this->values as $number_variable => $variable) {
$values[$number_variable] = (int) $variable;
}
$area = new area();
$area->set_default_dot_style(new hollow_dot());
$area->set_colour('#5B56B6');
$area->set_fill_alpha(0.4);
$area->set_values($values);
$area->set_key('Values', 12);
$x_labels = new x_axis_labels();
$x_labels->set_steps(1);
$x_labels->set_vertical();
$x_labels->set_colour('#A2ACBA');
$x_labels->set_labels($this->legend);
$x = new x_axis();
$x->set_colour('#A2ACBA');
$x->set_grid_colour('#D7E4A3');
$x->set_offset(false);
$x->set_steps(1);
// Add the X Axis Labels to the X Axis
$x->set_labels($x_labels);
$y = new y_axis();
$y_max = max($values) > 0 ? max($values) : 4;
$y_mod = (int) ($y_max / 4 + 1);
$y_max += $y_mod - $y_max % $y_mod;
$y->set_range(0, $y_max, $y_mod);
$y->labels = null;
$y->set_offset(false);
$chart = new open_flash_chart();
$chart->set_x_axis($x);
$chart->add_y_axis($y);
$chart->add_element($area);
return $chart;
}
示例2: title
include '../php-ofc-library/open-flash-chart.php';
$chart = new open_flash_chart();
$chart->set_title(new title('Area Chart'));
//
// Make our area chart:
//
$area = new area();
// set the circle line width:
$area->set_width(2);
$area->set_default_dot_style(new hollow_dot());
$area->set_colour('#838A96');
$area->set_fill_colour('#E01B49');
$area->set_fill_alpha(0.4);
$area->set_values($data);
// add the area object to the chart:
$chart->add_element($area);
$y_axis = new y_axis();
$y_axis->set_range(-2, 2, 2);
$y_axis->labels = null;
$y_axis->set_offset(false);
$x_axis = new x_axis();
$x_axis->labels = $data;
$x_axis->set_steps(2);
$x_labels = new x_axis_labels();
$x_labels->set_steps(4);
$x_labels->set_vertical();
// Add the X Axis Labels to the X Axis
$x_axis->set_labels($x_labels);
$chart->add_y_axis($y_axis);
$chart->x_axis = $x_axis;
echo $chart->toPrettyString();
示例3: GetRenderContent
//.........这里部分代码省略.........
$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);
$aRes = CMDBSource::QueryToArray($sSql);
$aGroupBy = array();
$aLabels = array();
$iTotalCount = 0;
foreach ($aRes as $iRow => $aRow) {
示例4: axis
/**
* Use this method to set up the axis' range and labels. There are also a number
* of options (mostly styling) that can be set up. The two axis have different
* options, but a full documentation can be found on the links given under.
* Importantly though, the y has a range option that takes an array with 3 values
* (minimum value, max value and step size). On the x axis you will often want
* to use the labels from the dataset and the helper will add those labels if
* you have defined a proper labels path, either as the third parameter of
* setDate() or using the setLabelsPat() method. Note, that even if you require
* no options for the x-axis, you will have to call this method on that axis
* for it to use those labels.
*
* See documentation for options ;
* http://teethgrinder.co.uk/open-flash-chart-2/x-axis.php
* http://teethgrinder.co.uk/open-flash-chart-2/y-axis.php
*
* @example $flashChart->axis('x'); //Sets labels from dataset
* @example $flashChart->axis('x',array('labels'=>array('Things','To','Do')),array('colour'=>'#aaFF33', 'vertical'=>true));
* @example $flashChart->axis('y', array('range'=>array(0,50,5), 'tick_length'=>15);
* @param string $axis 'x' or 'y'
* @param array $options
* @param array $labelsOptions used to customize x axis labels
*/
public function axis($axis, $options = array(), $labelsOptions = array())
{
$axis_object_name = $axis . '_axis';
$axis_set_method = 'set_' . $axis . '_axis';
$axis_object = new $axis_object_name();
foreach ($options as $key => $setting) {
// special options set direcly bellow
if (in_array($key, array('labels', 'range'))) {
continue;
}
$set_method = 'set_' . $key;
if (is_array($setting)) {
switch ($key) {
case 'colours':
$axis_object->set_colours($setting[0], $setting[1]);
break;
default:
$axis_object->{$set_method}($setting);
}
} else {
$axis_object->{$set_method}($setting);
}
}
// that wich must always be set :
if (!isset($options['colour'])) {
$axis_object->set_colour($this->grid_colour);
}
if (!isset($options['grid_colour'])) {
$axis_object->set_grid_colour($this->grid_colour);
}
if (isset($options['range'])) {
if (isset($options['range'][0])) {
$min = $options['range'][0];
} else {
$min = $this->defaultRange[$axis][0];
}
if (isset($options['range'][1])) {
$max = $options['range'][1];
} else {
$max = $this->defaultRange[$axis][1];
}
if (isset($options['range'][2])) {
$step = $options['range'][2];
} else {
$step = $this->defaultRange[$axis][2];
}
if ($axis == 'y') {
$axis_object->set_range($min, $max, $step);
} else {
// $axis == 'x'
$axis_object->set_range($min, $max);
$axis_object->set_steps($step);
}
} else {
if ($axis == 'y') {
$axis_object->set_range($this->defaultRange[$axis][0], $this->defaultRange[$axis][1], $this->defaultRange[$axis][2]);
}
}
if ($axis == 'x' && is_string($this->labelsPath) && !empty($this->labelsPath)) {
if (sizeof($labelsOptions) > 0) {
$labels = Set::extract($this->data, $this->labelsPath);
$x_axis_label = new x_axis_labels();
foreach ($labelsOptions as $key => $setting) {
$set_method = 'set_' . $key;
$x_axis_label->{$set_method}($setting);
}
$x_axis_label->set_labels($labels);
$axis_object->set_labels($x_axis_label);
} else {
$labels = Set::extract($this->data, $this->labelsPath);
$axis_object->set_labels_from_array($labels);
}
} elseif (isset($options['labels']) && is_array($options['labels']) && $axis == 'x') {
if (isset($labelsOptions['vertical']) && $labelsOptions['vertical'] == true) {
$x_axis_label = new x_axis_labels();
$x_axis_label->set_vertical();
$x_axis_label->set_labels($options['labels']);
//.........这里部分代码省略.........
示例5: getNewUsersByTime
function getNewUsersByTime($timePhase, $fromDate = '', $toDate = '')
{
$this->load->library('ofc');
$userId = $this->common->getUserId();
$this->ofc->open_flash_chart();
$this->ofc->set_bg_colour(CHART_BG_COLOR);
$toTime = date("Y-m-d", strtotime("-1 day"));
if ($timePhase == "7day") {
$fromTime = date("Y-m-d", strtotime("-8 day"));
$color = CHART_LINE_1;
$key = "近7日新增用户";
$title = new title("近7日新增用户统计");
}
if ($timePhase == "1month") {
$title = new title("近30天新增用户统计");
$fromTime = date("Y-m-d", strtotime("-31 day"));
$color = CHART_LINE_2;
$key = "近30天新增用户统计";
}
if ($timePhase == "3month") {
$title = new title("近三个月新增用户统计");
$fromTime = date("Y-m-d", strtotime("-92 day"));
$color = CHART_LINE_3;
$key = "近三个月新增用户统计";
}
if ($timePhase == "all") {
$title = new title("所有新增用户统计");
$fromTime = '1970-01-01';
$color = CHART_LINE_4;
$key = "所有新增用户统计";
}
if ($timePhase == "any") {
$title = new title("所有新增用户统计");
$fromTime = $fromDate;
$toTime = $toDate;
$color = CHART_LINE_4;
$key = "所有新增用户统计";
}
$fromTime = $this->product->getUserStartDate($userId, $fromTime);
$query = $this->newusermodel->getNewUsersByUserId($fromTime, $toTime, $userId);
$data = array();
$maxY = 0;
$recordCount = $query->num_rows();
$steps = $recordCount - 1 <= 10 ? 2 : (int) (((int) $recordCount - 1) / 10);
$xlabelArray = array();
if ($query != null && $query->num_rows() > 0) {
foreach ($query->result() as $row) {
$dot = new dot();
$dot->size(3)->halo_size(1)->colour($color);
$dot->tooltip($row->startdate . " 新增" . $row->totalusers . "用户");
$dot->value((int) $row->totalusers);
if ((int) $row->totalusers > $maxY) {
$maxY = (int) $row->totalusers;
}
array_push($xlabelArray, date('y-m-d', strtotime($row->startdate)));
array_push($data, $dot);
}
}
$y = new y_axis();
$y->set_range(0, $this->common->getMaxY($maxY), $this->common->getStepY($maxY));
$x = new x_axis();
$x->set_range(0, $recordCount > 1 ? $recordCount - 1 : 1);
$x_labels = new x_axis_labels();
$x_labels->set_steps($steps);
$x_labels->set_vertical();
$x_labels->set_colour(CHART_LABEL_COLOR);
$x_labels->set_size(13);
$x_labels->set_labels($xlabelArray);
$x_labels->rotate(-25);
$x->set_labels($x_labels);
$x->set_steps(1);
$this->ofc->set_y_axis($y);
$this->ofc->set_x_axis($x);
$dot = new dot();
$dot->size(3)->halo_size(1)->colour($color);
$line = new line();
$line->set_default_dot_style($dot);
$line->set_values($data);
$line->set_width(2);
$line->set_colour($color);
$line->colour($color);
$line->set_key($key, 12);
$this->ofc->add_element($line);
$title->set_style("{font-size: 14px; color:#000000; font-family: Verdana; text-align: center;}");
// $x_legend = new x_legend("<a href=\"javascript:changeChartName('chartNewUser')\">新增用户</a> <a href=\"javascript:changeChartName('chartActiveUser')\">活跃用户</a> <a href=\"javascript:changeChartName('chartStartUser')\">启动用户</a>");
// $this->ofc->set_x_legend( $x_legend );
// $x_legend->set_style( '{font-size: 14px; color: #778877}' );
$this->ofc->set_title($title);
echo $this->ofc->toPrettyString();
}
示例6: array
/**
* assign the chartdata object for open flash chart library
* @param $config
* @return unknown_type
*/
function _setChartdata($config)
{
$model = $this->getModel();
$rounds = $this->get('Rounds');
$round_labels = array();
foreach ($rounds as $r) {
$round_labels[] = $r->name;
}
$division = $this->get('division');
$data = $model->getDataByDivision($division->id);
//create a line
$length = count($rounds) - 0.5;
$linewidth = $config['color_legend_line_width'];
$lines = array();
//$title = $division->name;
$chart = new open_flash_chart();
//$chart->set_title( $title );
$chart->set_bg_colour($config['bg_colour']);
//colors defined for ranking table lines
//todo: add support for more than 2 lines
foreach ($this->colors as $color) {
foreach ($rounds as $r) {
for ($n = $color['from']; $n <= $color['to']; $n++) {
$lines[$color['color']][$n][] = $n;
}
}
}
//set lines on the graph
foreach ($lines as $key => $value) {
foreach ($value as $line => $key2) {
$chart->add_element(hline($key, $length, $line, $linewidth));
}
}
//load team1, first team in the dropdown
$team = $this->team1;
$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($team->rankings);
$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);
//load team2, second team in the dropdown
$team = $this->team2;
$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($team->rankings);
$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 = new x_axis();
if ($config['x_axis_label'] == 1) {
$xlabels = new x_axis_labels();
$xlabels->set_labels($round_labels);
$xlabels->set_vertical();
}
$x->set_labels($xlabels);
$x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
$chart->set_x_axis($x);
$x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_CURVE_ROUNDS'));
$x_legend->set_style('{font-size: 15px; color: #778877}');
$chart->set_x_legend($x_legend);
$y = new y_axis();
$y->set_range(count($data), 1, -1);
$y->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
$chart->set_y_axis($y);
$y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_CURVE_RANK'));
$y_legend->set_style('{font-size: 15px; color: #778877}');
$chart->set_y_legend($y_legend);
ob_clean();
echo $chart->toString();
}
示例7: 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};
//.........这里部分代码省略.........
示例8: 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;
}
示例9: 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 />";
}
示例10: create_line_graph
/**
* Create a single line graph
*
* @param string $title Title of the graph
* @param array $values Array of values
* @param array $titles Array of titles
* @return none
*
*/
public static function create_line_graph($title)
{
self::init();
$d = new solid_dot();
$d->size(3)->halo_size(1)->colour('#3D5C56');
$range_values = array();
foreach (self::$data_set as $data) {
if (!is_array($data['values'])) {
continue;
}
$line = new line();
$line->set_default_dot_style($d);
$line->set_values($data['values']);
$line->set_width(2);
$line->set_key($data['line_title'], 10);
$line->set_colour($data['color']);
# Since there should be an even number on the xaxis for all sets
$x_axis_titles = $data['titles'];
# Add our values into a big bucket so we can get the highest and lowest
$range_values = array_merge($range_values, $data['values']);
self::$chart->add_element($line);
}
$x_labels = new x_axis_labels();
$x_labels->set_labels($x_axis_titles);
$x_labels->set_vertical();
self::$x_axis->set_labels($x_labels);
$range = self::get_range($range_values);
self::$y_axis->set_range($range['min'], $range['max']);
self::show_chart($title);
}
示例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: getChartDataString
public function getChartDataString()
{
$values = $this->values;
$chart = $this->chart;
$line = self::getChartInstance();
$line->set_values($values['x']);
if (self::LINE == $this->chartType) {
$line->set_halo_size(2);
$line->set_dot_size(2);
}
if (self::PIE == $this->chartType) {
$line->set_animate(false);
}
$chart->add_element($line);
$x = new x_axis();
$x_labels = new x_axis_labels();
if ('hour' != $this->interval) {
$x_labels->set_vertical();
}
$x_labels->set_labels($values['y']);
if ('hour' != $this->interval) {
$x_labels->set_steps(ceil(count($values['y']) / 13));
}
if (self::PIE == $this->chartType) {
$line->set_tooltip('#label# (#percent#)');
$line->set_colours(array('#77CC6D', '#FF5973', '#6D86CC', '#848484', '#CACFBE', '#1F8FA1'));
} else {
$line->set_tooltip('#x_label#: #val#');
}
$x->set_labels($x_labels);
$chart->set_x_axis($x);
$y = new y_axis();
if (isset($values['min'])) {
$y->set_range($values['min'], $values['max'], $values['step']);
}
$chart->add_y_axis($y);
return $chart->toPrettyString();
}
示例13: get_linear_graph
function get_linear_graph($dates, $vals, $keys = array())
{
include 'php-ofc-library/open-flash-chart.php';
$max_y = 0;
$arr_filled = array();
for ($i = 0; $i < count($dates); $i++) {
$year[] = $dates[$i];
for ($m = 0; $m < count($vals); $m++) {
$price[$m][] = (int) $vals[$m][$i];
if ($max_y < (int) $vals[$m][$i]) {
$max_y = (int) $vals[$m][$i];
}
if (@$arr_filled[$m] != $vals[$m][$i] and @$arr_filled[$m] == 0) {
@($arr_filled[$m] = (int) $vals[$m][$i]);
}
}
}
while ($max_y % 10 != 0) {
$max_y++;
}
$chart = new open_flash_chart();
//$title = new title( 'UK Petrol price (pence) per Litre' );
$d = new anchor();
if (count($dates) > 60) {
$d->size(2);
} else {
$d->size(3);
}
$d->halo_size(1);
$d->colour('#3D5C56');
$d->rotation(0);
$d->sides(4);
for ($i = 0; $i < count($price); $i++) {
if ($arr_filled[$i] == 0) {
continue;
}
if ($i == 0) {
$color = '#5E0722';
} elseif ($i == 1) {
$color = '#00FF00';
} else {
$color = '#FF0000';
}
$area = new area();
$area->set_colour($color);
$area->set_default_dot_style($d);
$area->set_values($price[$i]);
if (isset($keys[$i])) {
$area->set_key($keys[$i], 12);
}
// mb_convert_encoding($keys[$i], "UTF-8", "Windows-1251")
$area->set_width(2);
$chart->add_element($area);
}
$x_labels = new x_axis_labels();
if (count($dates) > 40) {
$x_labels->set_steps(7);
} else {
$x_labels->set_steps(1);
}
$x_labels->set_vertical();
$x_labels->set_colour('#000000');
$x_labels->set_labels($year);
$x_labels->rotate(-55);
$x_labels->set_size(12);
$x = new x_axis();
$x->set_colour('#000000');
$x->set_grid_colour('#DDDDDD');
//$x->set_offset( false );
$x->set_steps(1);
// Add the X Axis Labels to the X Axis
$x->set_labels($x_labels);
$chart->set_x_axis($x);
$y = new y_axis();
$y->set_range(0, $max_y);
$y->set_colour('#000000');
$y->set_grid_colour('#DDDDDD');
$chart->add_y_axis($y);
$chart->set_bg_colour("#FFFFFF");
?>
<script type="text/javascript" src="script/json/json2.js"></script>
<script type="text/javascript" src="script/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("open-flash-chart.swf", "my_chart", "600", "350", "9.0.0");
</script>
<script type="text/javascript">
function ofc_ready()
{
}
function open_flash_chart_data()
{
return JSON.stringify(data);
}
//.........这里部分代码省略.........