Location: PHPKode > projects > Pindorama > pindorama/active/components/graph.php
<?php
/**
*                                                          
* @name    Pindorama Core Configuration                    
* @version 0.1
* @author  Guilherme Capilé <hide@address.com>           
*                                                          
*/


/**
*                                                          
* @name        pin_xml_graph
* @deprecated  
* @version     0.11
*
* @author      Guilherme Capilé <hide@address.com>
*
* @param       $xmldata
* @param       $cachefile
*
* @global      $acom
* @global      $c
* @global      $str
* @global      $format
* @global      $ci
* @global      $ic
* @global      $d
* @global      $box
* 
* @see         pin_redirect()
* @see         pin_xml2php()
*
* @return      
*/    
function pin_xml_graph($xmldata, $cachefile)
{
    global $acom, $c, $str, $format, $ci, $ic, $d, $box;
    require_once($c["components"]."jpgraph/jpgraph.php");
    require_once($c["components"]."jpgraph/jpgraph_line.php");
    $data = pin_xml2php($xmldata);

    if (!is_numeric($data["width"][0])) {
        $data["width"][0] = 300;
    }
    if (!is_numeric($data["height"][0])) {
        $data["height"][0] = 200;
    }
    // Setup the graph
    $graph = new Graph($data["width"][0],$data["height"][0]);
    $graph->img->SetImgFormat('png'); 
    $graph->SetMarginColor('white');
    $graph->SetScale("textlin");
    $graph->SetFrame(false);
    $graph->SetMargin(40,40,30,30);
    
    $graph->title->Set($data["name"][0]);
    //$graph->title->SetFont(FF_ARIAL,FS_BOLD,13);
    $graph->xaxis->title->Set($data["name-x"][0]);
    $graph->yaxis->title->Set($data["name-y"][0]);    
    //$graph->xaxis->title->SetFont(FF_ARIAL);
    //$graph->yaxis->title->SetFont(FF_ARIAL);
    $graph->yaxis->HideZeroLabel();
    $graph->ygrid->SetFill(true,'#hide@address.com','#hide@address.com');
    $graph->xgrid->Show();
    
    //$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
    $graph->xaxis->SetTickLabels($data["region"]);
    
    $color = array("#339933", "#333399", "#993399", "#999933", "#993333");
    
    for ($i = 1; $i <= 5; $i++){
        if (count($data["value-$i"]) > 0) {
            // Create the first line
            $p[$i] = new LinePlot($data["value-$i"]);
            $p[$i]->SetColor($color[$i -1]);
            $p[$i]->SetLegend($data["name-$i"][0]);
            //$p[$i]->SetWeight(3);
            $graph->Add($p[$i]);
        }
    }
    /*
    // Create the second line
    $p2 = new LinePlot($datay2);
    $p2->SetColor("red");
    $p2->SetLegend('Line 2');
    $graph->Add($p2);
    
    // Create the third line
    $p3 = new LinePlot($datay3);
    $p3->SetColor("orange");
    $p3->SetLegend('Line 3');
    $graph->Add($p3);*/
    
    $graph->img->SetAntiAliasing(); 
    $graph->legend->SetShadow('hide@address.com',5);
    $graph->legend->SetPos(0.1,0.1,$data["align-hl"][0],$data["align-vl"][0]);
    // Output line
    $graph->Stroke($cachefile);
}


/**
*                                                          
* @name        pin_xml2php
* @deprecated  
* @version     0.11
*
* @author      Guilherme Capilé <hide@address.com>
*
* @param       $xmldata
* @param       $cachefile
*
* @global      $arg
* @global      $param
* @global      $format
* @global      $ci
* @global      $ic
* @global      $d
* @global      $box
* 
* @see         pin_xsl_process()
*
* @return      
*/  
function pin_xml2php ($xml)
{
    global $arg, $param, $c;
    $result = false;
    $arg["xml"] = $xml;
    $arg["xsl"] = <<<FIM
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="iso-8859-1" indent="no" method="xml" omit-xml-declaration="yes"/>
<xsl:variable name="from">"</xsl:variable>
<xsl:variable name="to">'</xsl:variable>
<xsl:template match="/">\$result = <xsl:apply-templates />;</xsl:template>
<xsl:template match="*[normalize-space(.) != '']"><xsl:variable name="name" select="name()"/><xsl:if test="not(preceding-sibling::*[name() = \$name])">"<xsl:value-of select='name()'/>"<xsl:text disable-output-escaping="yes">=&gt;</xsl:text>array(<xsl:for-each select="../*[name() = \$name]">"<xsl:value-of select='translate(., \$from, \$to)'/>"<xsl:if test="position() != last()">, </xsl:if></xsl:for-each>), </xsl:if></xsl:template>
<xsl:template match="*[count(*) &gt; 0]">array(<xsl:apply-templates />)<xsl:if test="position() != last()">, </xsl:if></xsl:template>
</xsl:stylesheet>
FIM;
    $res = pin_xsl_process("arg:xml", "arg:xsl");
    $res = str_replace(", )", ")", $res);
    eval($res);
    return $result;
}

?>
Return current item: Pindorama