Hej
Jeg er ved at lave et modul der viser noget statistik over mine ordrer. Jeg bruger Open Flash Chart.
Jeg ønsker at lave det sådan, så når $daysago bliver størrer end 30 dage (en måned), så looper den ikke alle dagene men istedet bliver lavet om, og looper det antal måneder som er valgt.
Håber i forstår...
$inputs1 = explode('-','2008-09-15');
$year1 = $inputs1[0];
$month1 = $inputs1[1];
$day1 = $inputs1[2];
$inputs2 = explode('-','2008-10-15';
$year2 = $inputs2[0];
$month2 = $inputs2[1];
$day2 = $inputs2[2];
$start_date = "$year1-$month1-$day1";
$end_date = "$year2-$month2-$day2";
$date = mktime(0,0,0,$month1,$day1,$year1); //Gets Unix timestamp START DATE
$date1 = mktime(0,0,0,$month2,$day2,$year2); //Gets Unix timestamp END DATE
$difference = $date1-$date; //Calcuates Difference
$daysago = floor($difference /60/60/24); //Calculates Days Old
$i = 0;
while ($i <= $daysago +1) {
if ($i != 0) { $date = $date + 86400; }
else { $date = $date - 86400; }
$today = date('Y-m-d',$date);
$datas = mysql_fetch_array(mysql_query("SELECT COUNT(order_id) AS orders FROM vaerumshop_orders
WHERE order_date LIKE '%$today%'"));
$data[] = $datas['orders'];
$dates[] = $today;
$i++;
}
$max = max($data);
$steps = round($max/2);
include_once( 'open-flash-chart.php' );
$g = new graph();
$g->title( 'Ordrer', '{font-size: 20px; color: #000000}' );
$g->set_y_legend( 'Antal Ordrer', 12, '#000000' );
// we add 3 sets of data:
$g->set_data( $data );
// we add the 3 line types and key labels
$g->line_hollow( 2, 4, '0x80a033', 'Antal Ordrer', 10 );
$g->set_x_labels( $dates );
$g->set_x_label_style( 10, '0x000000', 0, 2 );
$g->x_axis_colour( '#909090', '#ADB5C7' );
$g->y_axis_colour( '#909090', '#ADB5C7' );
$g->set_x_label_style( 11, '#303030', 2 );
$g->set_y_label_style( 11, '#303030', 2 );
$g->bg_colour = '#FDFDFD';
$g->set_y_max( $max );
$g->y_label_steps( $steps );
echo $g->render();
Indlæg senest redigeret d. 15.10.2008 13:22 af Bruger #8297