<?php
//  All of the documentation and software included in the PHP Climate
//  Release is copyrighted by Sebastien Windal
//
//  Copyright 2002
//  Sebastien Windal.  All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are met:
//  1. Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//  2. Redistributions in binary form must reproduce the above copyright
//     notice, this list of conditions and the following disclaimer in the
//     documentation and/or other materials provided with the distribution.
//  3. All advertising materials mentioning features or use of this software
//     must display the following acknowledgement:
//     This product includes software developed by Sebastien Windal and their
//     contributors.
//  4. Neither my name nor the names of its contributors may be used to
//     endorse or promote products derived from this software without
//     specific prior written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
//  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
//  ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
//  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
//  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
//  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
//  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
//  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
//  SUCH DAMAGE.
//

require_once "jpgraph.php";
require_once 
"jpgraph_line.php";

//Dual temperature graph. Create a graph which compares temperatures
//for two locations (named loc1 and loc2). Normal monthly temp are
//passed into max1 and  max2 (normal maxima for each location), min1 
//and min2 (normal minima for each location).
class temp_graph extends graph
{
    
//--------------------------------------------------------------------
    //Constructor:
    
function temp_graph($loc1$loc2$metric,
                
$min1$max1$min2$max2$single)
    {

        
$month = array("Jan""Feb""Mar""Apr""May""Jun",
                   
"Jul""Aug""Sep""Oct""Nov""Dec");

        
$this->graph(500280"auto");
        
$this->img->SetMargin(50,100,40,50); //left, right, top, bottom
        
$this->SetScale("textlin");
        
$this->SetMarginColor('white');
        
$this->SetFrame(false);

        
$this->legend->Pos(0.020.04);

        
//Use built in font (don't need TTF support)
        
$this->title->SetFont(FF_FONT2,FS_BOLD);

        
// Setup X-axis labels
        
$this->xaxis->SetTickLabels($month);
        
$this->xaxis->SetLabelAngle(90);
        
$this->xaxis->SetPos('min');


        
//Create lineplots
        
$lineplot_min1 = new LinePlot($min1);
        
$lineplot_min1->SetLegend("$loc1 min.");
        
$lineplot_min1->SetColor("blue");
        
$lineplot_min1->SetWeight(1);

        
$lineplot_max1 = new LinePlot($max1);
        
$lineplot_max1->SetLegend("$loc1 max.");
        
$lineplot_max1->SetColor("red");
        
$lineplot_max1->SetWeight(1);

        if (
$single!="true") {
            
$lineplot_min2 = new LinePlot($min2);
            
$lineplot_min2->SetLegend("$loc2 min.");
            
$lineplot_min2->SetColor("blue");
            
$lineplot_min2->SetStyle('dashed');
            
$lineplot_min2->SetWeight(1);

            
$lineplot_max2 = new LinePlot($max2);
            
$lineplot_max2->SetLegend("$loc2 max.");
            
$lineplot_max2->SetColor("red");
            
$lineplot_max2->SetStyle('dashed');
            
$lineplot_max2->SetWeight(1);
        }

        
//add them to the graPH
        
$this->Add($lineplot_max1);
        
$this->Add($lineplot_min1);
        if (
$single != "true") {
            
$this->Add($lineplot_max2);
            
$this->Add($lineplot_min2);
        }
        
$this->title->Set("Temperatures");

        if (
$metric=="true")
            
$unitname "(C)";
        else
            
$unitname "(F)";
        
$this->yaxis->title->Set("Temperature $unitname");
    }
}
?>