Location: PHPKode > projects > WillCool > WillCool_v2.0/frame_month_get_graph_bb.php
<?php
/*
####################################################
#                                                  #
# AUTHOR: William Massey                           #
# DATE: 15-feb-2007                                #
#                                                  #
####################################################

Copyright 2007 William Massey

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
	//open datafile and create array of each line. Call each value as follows: $array[key]
	$fp=fopen('frame_month_bb.txt',"r");
	if ($fp){
		while(!feof($fp)) {
		$line=fgets($fp);
		list($key,$value) = split("[[:space:]]+",$line);
		$array[$key] = $value;
	//echo "$key is $value";
	}
	fclose($fp);
	}
	else {
		$array[$key] = 20;
	}

    include("Image/Graph.php");
    $Graph =& new Image_Graph(233, 130);

    $PlotArea =& $Graph->add(new Image_Graph_PlotArea());

    $DataSet =& new Image_Graph_Dataset_Trivial();    // create the dataset
    $DataSet->addPoint(1, $array[subcountday30]);
    $DataSet->addPoint(2, $array[subcountday29]);
    $DataSet->addPoint(3, $array[subcountday28]);
    $DataSet->addPoint(4, $array[subcountday27]);
    $DataSet->addPoint(5, $array[subcountday26]);
    $DataSet->addPoint(6, $array[subcountday25]);
    $DataSet->addPoint(7, $array[subcountday24]);
    $DataSet->addPoint(8, $array[subcountday23]);
    $DataSet->addPoint(9, $array[subcountday22]);
    $DataSet->addPoint(10, $array[subcountday21]);
    $DataSet->addPoint(11, $array[subcountday20]);
    $DataSet->addPoint(12, $array[subcountday19]);
    $DataSet->addPoint(13, $array[subcountday18]);
    $DataSet->addPoint(14, $array[subcountday17]);
    $DataSet->addPoint(15, $array[subcountday16]);
    $DataSet->addPoint(16, $array[subcountday15]);
    $DataSet->addPoint(17, $array[subcountday14]);
    $DataSet->addPoint(18, $array[subcountday13]);
    $DataSet->addPoint(19, $array[subcountday12]);
    $DataSet->addPoint(20, $array[subcountday11]);
    $DataSet->addPoint(21, $array[subcountday10]);
    $DataSet->addPoint(22, $array[subcountday9]);
    $DataSet->addPoint(23, $array[subcountday8]);
    $DataSet->addPoint(24, $array[subcountday7]);
    $DataSet->addPoint(25, $array[subcountday6]);
    $DataSet->addPoint(26, $array[subcountday5]);
    $DataSet->addPoint(27, $array[subcountday4]);
    $DataSet->addPoint(28, $array[subcountday3]);
    $DataSet->addPoint(29, $array[subcountday2]);
    $DataSet->addPoint(30, $array[subcountday1]);
        
    $Plot =& $PlotArea->addPlot(new Image_Graph_Plot_Line($DataSet));
        
    // set a line color for plot line
    $Plot->setLineColor(IMAGE_GRAPH_RED);
    
    $Arial =& $Graph->addFont(new Image_Graph_Font_TTF("C:\WINDOWS\Fonts\arial.TTF"));
    $Arial->setSize(7);
    $BLUE =& $Graph->newColor(0,102,153);
    $Arial->setColor($BLUE);
    
    // set the axis properties
    $AxisY =& $PlotArea->getAxis(IMAGE_GRAPH_AXIS_Y);    
    $AxisY->forceMinimum(2.5);
    $AxisY->forceMaximum(2.91);
    $AxisY->setLabelInterval(0.1);
    $AxisY->setLineColor($BLUE);
    $AxisY->setFont($Arial);
    $AxisY->setDataPreprocessor(new Image_Graph_DataPreprocessor_Formatted("%.1fM"));
    //$AxisY->forceOffset(10);
    // X
    $AxisX =& $PlotArea->getAxis(IMAGE_GRAPH_AXIS_X);    
    //$AxisX->forceMinimum(10);
    //$AxisX->forceMaximum(150000);
    $AxisX->setLabelInterval(5);
    $AxisX->setLineColor($BLUE);
    $AxisX->setFont($Arial);
    //$AxisY->showArrow();
   
    // output the Graph
    $Graph->done();
?>
Return current item: WillCool