Location: PHPKode > projects > TVEz - Media Library > tvez-0.2.1/html/shared/Graph/bar_graph.php
<?php

# -----------------------------------------------------------------------------
#
# Wrapper for the BarGraph class
#
# Parses the query string and outputs an image
#
# -----------------------------------------------------------------------------
#
# Copyright (C) 2004 Christian Eheim
#
# 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/01/2004 by Christian Eheim (hide@address.com)
#
# LAST MODIFIED:
# $Date: 2004/02/03 23:22:00 $
# $Revision: 1.1 $
# $Author: eheim $
#
# -----------------------------------------------------------------------------

$data  = urldecode($_GET['data']);

$title = null;
$width = 400;
$height = 250;

if (isset($_GET['title'])) $title = $_GET['title'];
if (isset($_GET['height'])) $height = $_GET['height'];
if (isset($_GET['width'])) $width = $_GET['width'];

$items = explode("^^", $data);

include("../../shared/Graph/BarGraph.php");

$plot = new BarGraph($width,$height,$title);

while (list($key,$item) = each($items)) {
	if ($item) {
	 $pos = strpos($item, "^");
	 $label = substr($item, 0, $pos);
	 $value = substr($item, $pos + 1, strlen($item));

	$plot->add_data_value($label,$value);
	}
}

if (! $title)
	$plot->set_margin(10,5,3,5);

if (isset($_GET['xTitle']))
	$plot->set_x_axis_title($_GET['xTitle']);
if (isset($_GET['yTitle']))
	$plot->set_y_axis_title($_GET['yTitle']);

if (isset($_GET['xTicks']))
	$plot->set_x_axis_num_ticks($_GET['xTicks']);
if (isset($_GET['xMin']))
	$plot->set_x_axis_min_value($_GET['xMin']);
if (isset($_GET['xMax']))
	$plot->set_x_axis_max_value($_GET['xMax']);

if (isset($_GET['yTicks']))
	$plot->set_y_axis_num_ticks($_GET['yTicks']);
if (isset($_GET['yMin']))
	$plot->set_y_axis_min_value($_GET['yMin']);
if (isset($_GET['yMax']))
	$plot->set_y_axis_max_value($_GET['yMax']);

if (isset($_GET['gradient']) && $_GET['gradient'])
	$plot->set_bar_gradient(true);
else
	$plot->set_bar_gradient(false);

if (isset($_GET['spacing']))
	$plot->set_bar_spacing($_GET['spacing']);
else
	$plot->set_bar_spacing(1);

if (isset($_GET['barBorder']) && $_GET['barBorder'])
	$plot->show_bar_border(true);
else
	$plot->show_bar_border(false);

if (isset($_GET['xLabelUp']) && $_GET['xLabelUp'])
	$plot->set_x_axis_label_up(true);
else
	$plot->set_x_axis_label_up(false);

$plot->set_y_axis_show_grid(true);
$plot->set_plot_bgcolor("white");

$plot->draw();
Return current item: TVEz - Media Library