<?php
srand((double)microtime()*1000000);
$data = array();
$now = time();
$dblink = MG::__new('db', $GLOBALS['dbSet']['datareport']);
$date_num = date('t', $now);
for( $i=1; $i<=$date_num; $i++ )
{
$day = strlen($i) == 1 ? "0$i" : $i;
$temp = $dblink -> Query("SELECT count(id) AS num FROM t_log_".date("Ym").$day);
//echo "SELECT count(id) AS num FROM t_log_".date("Y-m").$day;
$data[] = intval($temp['num']);
unset($temp);
$date_day[] = "D:$i";
}
//OFC_CHARTS define的一个路径
require_once(OFC_CHARTS.'php5-ofc-library/lib/OFC/OFC_Chart.php');
$title = new OFC_Elements_Title( date("Y-m") );
$bar = new OFC_Charts_Bar_3d();
$bar->set_values( $data );
$bar->colour = '#B452CD';
$x_axis = new OFC_Elements_Axis_X();
$x_axis -> set_3d(1);
$x_axis -> colour = '#ADFF2F';
//用数组设定X轴下标内容
$x_axis -> set_labels_from_array($date_day);
$y_axis = new OFC_Elements_Axis_Y();
$y_axis -> set_colour('#ADFF2F');
$y_axis -> set_tick_length(5);
//设置Y轴区间及步长
$y_axis -> set_range(0, 500000, 50000);
$chart = new OFC_Chart();
$chart -> set_title($title);
$chart -> add_element($bar);
$chart -> set_x_axis($x_axis);
$chart -> set_y_axis($y_axis);
echo $chart->toPrettyString();
exit;
?>
|