本文整理汇总了PHP中x_axis::set_range方法的典型用法代码示例。如果您正苦于以下问题:PHP x_axis::set_range方法的具体用法?PHP x_axis::set_range怎么用?PHP x_axis::set_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类x_axis
的用法示例。
在下文中一共展示了x_axis::set_range方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: array
function _render_statistic($x = array(), $yout = array(), $yin = array(), $type = 'bar', $points)
{
$this->load->helper('date');
$this->load->library('OpenFlashChartLib', NULL, 'OFCL');
$data_1 = array();
$data_2 = array();
$data_3 = array();
switch ($type) {
case 'bar':
for ($i = 0; $i <= $points; $i++) {
$data_1[$i] = $x[$i];
$data_2[$i] = (int) $yout[$i];
// force to integer
$data_3[$i] = (int) $yin[$i];
// force to integer
}
$data_1 = array_reverse($data_1);
$data_2 = array_reverse($data_2);
$data_3 = array_reverse($data_3);
$bar_1 = new bar();
$bar_1->set_values($data_3);
$bar_1->set_colour('#639F45');
$bar_1->key(lang('kalkun_incoming_sms'), 10);
$bar_1->set_tooltip('#x_label#<br>#val# SMS');
//$bar_1->set_key("SMS used in last 7 days", 10);
$bar_2 = new bar();
$bar_2->set_values($data_2);
$bar_2->set_colour('#21759B');
$bar_2->key(lang('kalkun_outgoing_sms'), 10);
$bar_2->set_tooltip('#x_label#<br>#val# SMS');
$x = new x_axis();
$labels = new x_axis_labels();
$labels->set_labels($data_1);
$labels->set_steps(1);
$x->set_labels($labels);
$y = new y_axis();
$max = max(max($data_2), max($data_3));
if ($max < 10) {
$max = 10;
}
$max = ceil($max / 5) * 5;
$range = ceil($max / 5);
$range = ceil($range / 10) * 10;
$y->set_range(0, $max, $range);
$element1 = $bar_1;
$element2 = $bar_2;
break;
case 'line':
for ($i = 0; $i <= 7; $i++) {
$data_1[$i] = new scatter_value($x[$i], $yin[$i]);
$data_2[$i] = new scatter_value($x[$i], $yout[$i]);
$data_3[$i] = (int) $yin[$i];
$data_4[$i] = (int) $yout[$i];
}
$def = new solid_dot();
$def->size(4)->halo_size(0)->colour('#21759B')->tooltip('#date:d M y#<br>#val# SMS');
$line_1 = new scatter_line('#639F45', 3);
$line_1->set_values($data_1);
$line_1->set_default_dot_style($def);
$line_1->set_key("Incoming SMS", 10);
$line_2 = new scatter_line('#21759B', 3);
$line_2->set_values($data_2);
$line_2->set_default_dot_style($def);
$line_2->set_key("Outgoing SMS", 10);
$x = new x_axis();
// grid line and tick every 10
$x->set_range(mktime(0, 0, 0, date("m"), date("d") - 7, date('Y')), mktime(0, 0, 0, date("m"), date("d"), date('Y')));
// show ticks and grid lines for every day:
$x->set_steps(86400);
$labels = new x_axis_labels();
// tell the labels to render the number as a date:
$labels->text('#date:M-d#');
// generate labels for every day
$labels->set_steps(86400);
// only display every other label (every other day)
$labels->visible_steps(1);
$labels->rotate(45);
// finally attach the label definition to the x axis
$x->set_labels($labels);
$y = new y_axis();
$max = max(max($data_3), max($data_4));
if ($max < 1) {
$max = 10;
}
$y->set_range(0, $max, round($max / 100) * 10);
$element1 = $line_1;
$element2 = $line_2;
break;
}
$chart = new open_flash_chart();
$chart->add_element($element1);
$chart->add_element($element2);
$chart->set_x_axis($x);
$chart->set_y_axis($y);
echo $chart->toPrettyString();
}
示例3: 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();
}
示例4: rsort
sort($the_sort);
$lowest = $the_sort[0];
rsort($the_sort);
$highest = $the_sort[0];
// get maximum value (for y-axis)
$the_sort = $the_value_array;
foreach ($the_checked_cols as $col) {
rsort($the_sort[$col]);
$maxima[] = $the_sort[$col][0];
}
rsort($maxima);
$maximum = $maxima[0];
//-----/end get ranges -----------------
// Prepare the x-axis
$x = new x_axis();
$x->set_range($lowest, $highest);
// Calculate the steps and visible steps
$step = ($highest - $lowest) / 60;
$step_vis = 2;
// do not allow steps to be less than 30 minutes
if ($step < 26400) {
# 86400
$step = 26400;
$step_vis = 1;
}
$x->set_steps($step);
$labels = new x_axis_labels();
$labels->text('#date:Y-m-d#');
$labels->set_steps($step);
$labels->visible_steps($step_vis);
$labels->rotate(90);
示例5:
// apply temp F to C conversion
$y=convertFtoC($row["$name_alt"]);
}
else {
// no conversion, so use raw value
$y=$row["$name_alt"];
}
$data[] = new scatter_value($x, $y);
}
}
$s_alt->set_values( $data );
}
// Prepare the x-axis
$x = new x_axis();
$x->set_range( $ranges['min_date'], $ranges['max_date'] );
// Calculate the steps and visible steps
$step=($ranges['max_date'] - $ranges['min_date'])/60;
$step_vis=2;
// do not allow steps to be less than 1 day
if ($step < 86400) {
$step = 86400;
$step_vis=1;
}
$x->set_steps($step);
$labels = new x_axis_labels();
$labels->text('#date:Y-m-d#');
$labels->set_steps($step);
$labels->visible_steps($step_vis);
$labels->rotate(90);
$x->set_labels($labels);
示例6: CONVERT
if (intval($dt) == 1) {
$dateRange = "DATE(ts) between CONVERT('2012-5-1',DATE) and CONVERT('" . Date('Y-m-d') . "',DATE)";
} else {
$dtt = explode("-", $dt);
$dateRange = "DATE(ts) between CONVERT('" . $dtt[0] . "',DATE) and CONVERT('" . $dtt[1] . "',DATE)";
}
$title = new title("Page Views using " . $br . " browser between date " . $dt);
$bar = new bar_glass(55, '#D54C78', '#C31812');
include_once 'db.php';
$q = mysql_query("select count(c_browser) as tot from tracker where c_id=1234 and c_browser='" . $br . "' and " . $dateRange);
$bar->set_values(array(1245, 1202, 455, 120, 3652, 454, 121, 452, 1023, 1054, 1500, 1245, 1278, 123, 6598, 6547, 6589, 6999, 7854, 7562, 5478, 1200, 1254, 1562, 5415, 2587, 4589));
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($bar);
$x = new x_axis();
$x->set_range(0, 31, 1);
$chart->set_x_axis($x);
$chart->set_y_axis($x);
$y = new y_axis();
$y->set_stroke(3);
$y->set_colour('#000000');
$y->set_tick_length(7);
$y->set_grid_colour('#000000');
// grid steps:
$y->set_range(0, 10000, 1000);
//$y_labels = new y_axis_labels();
//$y_labels->set_labels( array('Zero','One','Two','Three','Four','Five','Six','Seven','Eight') );
// visible labels steps:
//$y_labels->set_steps(4);
//$y->set_labels($y_labels);
//
示例7: clientstatAction
function clientstatAction()
{
if (!$this->clientdashboardfilter()) {
return;
}
$this->view->activeTab = 'clientstat';
// process data for chart
include 'open-flash-chart.php';
$request = $this->getRequest();
$this->view->campaign_id = $request->getParam('id');
$campaignModel = new Campaign();
$campaign = $campaignModel->fetchRow('id = ' . $this->view->campaign_id);
$this->_helper->layout->setLayout($this->getCampaignTemplate($campaign->id));
//if session not exist, get data from webservice
$reportMap = array();
$array_data = $this->getReportCountbyCampaign($campaign, 0, $reportMap);
$sum = 0;
foreach ($array_data as $date) {
$sum += $date;
}
$i = 0;
$maxY = 0;
foreach ($array_data as $date) {
$array_data[$i] = round($date * 100 / $sum, 1);
if ($array_data[$i] > $maxY) {
$maxY = $array_data[$i];
}
$i++;
}
// create chart
$array_create_date = array('0', '1', '2', '3', '4', '5', '6', '7');
$title = new title("Kraft Spraks Comments");
$title->set_style('{font-size: 14px; color: #FFFFFF; }');
$max_y = floor($maxY / 10) * 10 + 10;
$y = new y_axis();
$y->set_range(0, $max_y, 10);
$x = new x_axis();
$x_labels = new x_axis_labels();
$x_labels->set_labels($array_create_date);
$x_labels->set_size(11);
$x->set_labels($x_labels);
$x->set_range(0, 7, 1);
//There is a bug on the tooltip of bar: can not show #x_label#. So use bar_stack instead of bar here.
$bar = new bar_filled();
$array_bar_data[0] = new bar_value($array_data[0]);
$array_bar_data[0]->set_colour('#606060');
$array_bar_data[1] = new bar_value($array_data[1]);
$array_bar_data[1]->set_colour('#BE3304');
$array_bar_data[2] = new bar_value($array_data[2]);
$array_bar_data[2]->set_colour('#F2B538');
$array_bar_data[3] = new bar_value($array_data[3]);
$array_bar_data[3]->set_colour('#EE7904');
$array_bar_data[4] = new bar_value($array_data[4]);
$array_bar_data[4]->set_colour('#D4FD32');
$array_bar_data[5] = new bar_value($array_data[5]);
$array_bar_data[5]->set_colour('#B4EB35');
$array_bar_data[6] = new bar_value($array_data[6]);
$array_bar_data[6]->set_colour('#B1D764');
$array_bar_data[7] = new bar_value($array_data[7]);
$array_bar_data[7]->set_colour('#A1C463');
$bar->set_values($array_bar_data);
// $bar->set_tooltip('#x_label#: #val#');
// $bar = new bar_stack();
// $bar->set_colours(array( '#E2D66A', '#A0C361' ));
// foreach ($array_data as $date):
// $bar->append_stack(array((int)$date));
// endforeach;
$bar->set_tooltip('#val#%');
$x_legend = new x_legend('Positive');
$x_legend->set_style('{font-size: 30px; color: #FFFFFF; }');
$y_legend = new y_legend($this->view->translate('(%)'));
$y_legend->set_style('{font-size: 30px; color: #FFFFFF;}');
$tags = new ofc_tags();
$tags->font("Verdana", 14)->align_x_right();
$tag_y_value = -($max_y * 0.3);
$t = new ofc_tag(6.6, $tag_y_value);
$t->text($this->view->translate('Client_Report Positive'))->colour("#177A16");
$tags->append_tag($t);
$t2 = new ofc_tag(0.5, $tag_y_value);
$t2->text($this->view->translate('Client_Report Negative'))->colour("#D88569");
$tags->append_tag($t2);
$t3 = new ofc_tag(-1, $max_y);
$t3->text($this->view->translate('(%)'))->colour("#000000");
$tags->append_tag($t3);
$t4 = new ofc_tag(-0.7, $tag_y_value);
$t4->text($this->view->translate('Client_Report No opinion'))->colour("#5D5D5D");
$tags->append_tag($t4);
$this->view->chart3 = new open_flash_chart();
$this->view->chart3->set_title($title);
$this->view->chart3->add_element($bar);
$this->view->chart3->set_bg_colour('#FFFFFF');
$this->view->chart3->set_x_axis($x);
$this->view->chart3->set_y_axis($y);
$this->view->chart3->set_x_legend($x_legend);
$this->view->chart3->set_y_legend($y_legend);
$this->view->chart3->add_element($tags);
}
示例8: array
function admin_graphs($id = null)
{
App::import('Vendor', 'Newsletter.php-ofc-library', array('file' => 'php-ofc-library/open-flash-chart.php'));
//Configure::write('debug', 0);
//$this->layout = null;
// generate some random data
srand((double) microtime() * 1000000);
$title = new title(__d("newsletter", "Views per time", true));
$chart = new open_flash_chart();
$chart->set_title($title);
$newsletter = $this->Newsletter->read(null, $id);
// Views
$dates = array();
$values = array();
//// init sender class ////
App::import('Lib', 'Newsletter.ClassCollection');
$senderOpt = NewsletterConfig::load('sender');
if (!is_array($senderOpt)) {
$senderOpt = array('name' => $senderOpt);
}
$sender = ClassCollection::getObject('NewsletterSender', $senderOpt['name']);
//// query ////
$opt = array('type' => 'graph', 'query' => array('fields' => array('count(*) as nb', 'DATE(NewsletterEvent.date) as date'), 'conditions' => array('NewsletterSended.newsletter_id' => $id, 'or' => array('NewsletterEvent.action' => 'view', array('NewsletterEvent.action IS NULL', 'NewsletterEvent.url' => null))), 'group' => 'DATE(NewsletterEvent.date)', 'order' => 'DATE(NewsletterEvent.date)', 'model' => 'NewsletterEvent'));
$data = $this->_get_stats(array('viewByDays' => $opt), $newsletter, $sender);
//debug($data);
$dates = $data['viewByDays'];
$min_value = 99999999;
$max_value = 0;
foreach ($dates as $d => $val) {
if ($val < $min_value) {
$min_value = $val;
}
if ($val > $max_value) {
$max_value = $val;
}
}
if ($max_value == $min_value) {
$max_value++;
$min_value--;
}
$min_value = 0;
//debug($dates);
$min_date = key($dates);
end($dates);
$max_date = key($dates);
for ($cur_date = $min_date; $cur_date <= $max_date; $cur_date = $cur_date + 86400) {
$x = strtotime('00:00:00', $cur_date);
if (isset($dates[$cur_date])) {
$values[] = new scatter_value($x, $dates[$cur_date]);
} else {
$values[] = new scatter_value($x, 0);
}
}
if ($max_date == $min_date) {
$max_date += 86400;
}
//debug($values);
//pr($views);
$line_dot = new line();
$line_dot->set_values($values);
$line_dot->set_text("Views");
$chart->add_element($line_dot);
$y = new y_axis();
$y->set_range($min_value, $max_value, ($max_value - $min_value) / 10);
$x = new x_axis();
// grid line and tick every 10
$x->set_range(mktime(0, 0, 0, date("m", $min_date), date("d", $min_date), date("Y", $min_date)), mktime(0, 0, 0, date("m", $max_date), date("d", $max_date), date("Y", $max_date)));
// 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:d-m-Y#');
// generate labels for every day
$labels->set_steps(86400);
// only display every other label (every other day)
$labels->visible_steps(ceil(($max_date - $min_date) / 86400 / 20));
$labels->rotate(90);
$x->set_labels($labels);
$chart->set_x_axis($x);
$chart->set_y_axis($y);
$chart->set_bg_colour("#FFFFFF");
//print_r($views);
//$this->set("allviews",$views[0][0]['count(*)']);
$line_dot = new line();
$line_dot->set_values(array(2, 1));
$line_dot->set_text("Unique views");
$line_dot->colour("#0000000");
//$chart->add_element($line_dot);
//
echo $chart->toPrettyString();
exit;
//$this->render(false);
}