Location: PHPKode > projects > TVEz - Media Library > tvez-0.2.1/html/movies/stats/time_stat.php
<?php

# ------------------------------------------------------------------------------
#
# Top 10 Portlet
#
# ------------------------------------------------------------------------------
#
# Copyright (C) 2003 Christian Eheim and Alex Pachikov
#                                                                               
# This file is part of TVEz (tvez.sourceforge.net).
#                                                                               
# TVEz is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#                                                                               
# TVEz is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#                                                                               
# You should have received a copy of the GNU General Public License
# along with TVEz; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#                                                                               
# ------------------------------------------------------------------------------
#
# Created on 02/12/2003 by Christian Eheim (hide@address.com)
#
# LAST MODIFIED:
# $Date: 2004/02/03 23:21:29 $
# $Revision: 1.4 $
# $Author: eheim $
#
# ------------------------------------------------------------------------------

    $query = "SELECT round(time,-1) rtime,count(round(time,-1)) number from movies group by round(time,-1)";
    list($tnum,$time_movies) = query_db($query);
	$content = "";
	if ($tnum) {
		$cc = 0;
		while ( ($first = $time_movies[$cc]['rtime']) == 0 ) $cc++;
		$last = $time_movies[(sizeof($time_movies)-1)]['rtime'];
		foreach ($time_movies as $movie)
			$years[$movie['rtime']] = $movie['number'];

		$max = 0;
		$min = 0;
		$data = "";
		for ($i=$first; $i<=$last; $i+=10) {
			$height = (isset($years[$i])) ? $years[$i] : 0;
			$data .= "$i^$height^^";
			if ($height > $max) $max = $height;
		}
		if ($max>=100) {
			$max = ceil($max/20)*20;
			$yt = floor($max/20);
		}	
		else {
			$max = ceil($max/10)*10;
			$yt = floor($max/10);
		}

		$query = "width=500&height=200&gradient=true&yMin=$min&yMax=$max&yTicks=$yt&barBorder=true&xTitle=Runtime%20(min)&yTitle=Number%20of%20Movies&spacing=3&data=";
		$query .= $data;

		portlet(localize_string("Runtime Distribution"),'<img src="shared/Graph/bar_graph.php?'.$query.'">',"x");
	}
	else 
		portlet(localize_string("Runtime Distribution"),"No movie runtimes have been specified","x");

?>
Return current item: TVEz - Media Library