• User

    Librerie gd...cosa c'è che non va!?

    ...ciao mitici!

    Sapete svelarmi un mistero?

    Perchè questi capolavori (pchart.sourceforge.net) non mi funzionano, e queste ciofekine(makko.com.mx/gdgraph/) invece sì? :mmm:

    Proprio non mi capacito...nella mia ignoranza suppongo che tutte e due le classi sfruttino le librerie gd....ma perchè il primo non funziona? :arrabbiato:

    Tanto di cappello a makko, per carità, però pChart fa sbavare solo a vedere le anteprime! :tongueout:

    Aggiungo che ho Apache 2.2.8 e PHP 5.2.6....


  • User Attivo

    Ciao ciccio6630,

    la tua domanda e' un po' generica. Prova a darci piu' informazioni del tipo: quale errore ti da pchart?

    Facci sapere

    :ciauz:


  • User

    uno dei misteri è proprio questo: niente errori!

    Il php restituisce un output pulito come solo mastro lindo sa fare!

    Ti incollo un esempio a caso che in teoria dovrebbe funzionare:

    Example1.php
    [php]
    <?php

    include("pChart/pData.class");
    include("pChart/pChart.class");

    $DataSet = new pData;
    $DataSet->ImportFromCSV("Sample/bulkdata.csv",",",array(1,2,3),FALSE,0);
    $DataSet->AddAllSeries();
    $DataSet->SetAbsciseLabelSerie();
    $DataSet->SetSerieName("January","Serie1");
    $DataSet->SetSerieName("February","Serie2");
    $DataSet->SetSerieName("March","Serie3");

    $Test = new pChart(700,230);
    $Test->setFontProperties("Fonts/tahoma.ttf",8);
    $Test->setGraphArea(60,30,680,200);
    $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
    $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);
    $Test->drawGraphArea(255,255,255,TRUE);
    $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),5,150,150,150,TRUE,0,2);
    $Test->drawGrid(4,TRUE,230,230,230,50);

    $Test->setFontProperties("Fonts/tahoma.ttf",6);
    $Test->drawTreshold(0,143,55,72,TRUE,TRUE);

    $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());
    $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);

    $Test->setFontProperties("Fonts/tahoma.ttf",8);
    $Test->drawLegend(65,35,$DataSet->GetDataDescription(),255,255,255);
    $Test->setFontProperties("Fonts/tahoma.ttf",10);
    $Test->drawTitle(60,22,"example 1",50,50,50,585);
    $Test->Render("example1.png");
    ?>
    [/php]

    ...mi viene impossibile incollarti il sorgente delle classi perchè mi dice che non sono un utente premium.... :bho:


  • User

    ...che stupido...era perchè c'erano dei links...

    questo è pData.class

    [php]
    <?php
    /*
    pData - Simplifying data population for pChart
    Copyright (C) 2008 Jean-Damien POGOLOTTI
    Version 1.13 last updated on 07/24/08

     This program 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 1,2,3 of the License, or
     (at your option) any later version.
    
     This program 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 this program.  If not, see .
    
     Class initialisation :
      pData()
     Data populating methods :
      ImportFromCSV($FileName,$Delimiter=",",$DataColumns=-1,$HasHeader=FALSE,$DataName=-1)
      AddPoint($Value,$Serie="Serie1",$Description="")
     Series manipulation methods :
      AddSerie($SerieName="Serie1")
      AddAllSeries()
      RemoveSerie($SerieName="Serie1")
      SetAbsciseLabelSerie($SerieName = "Name")
      SetSerieName($Name,$SerieName="Serie1")
      removeSerieName($SerieName)
      removeAllSeries()
     Data retrieval methods :
      GetData()
      GetDataDescription()
    

    */

    /* pData class definition */
    class pData
    {
    var $Data;
    var $DataDescription;

    function pData()
    {
    $this->Data = "";
    $this->DataDescription = "";
    $this->DataDescription["Position"] = "Name";
    }

    function ImportFromCSV($FileName,$Delimiter=",",$DataColumns=-1,$HasHeader=FALSE,$DataName=-1)
    {
    $handle = @fopen($FileName,"r");
    if ($handle)
    {
    $HeaderParsed = FALSE;
    while (!feof($handle))
    {
    $buffer = fgets($handle, 4096);
    $buffer = str_replace(chr(10),"",$buffer);
    $buffer = str_replace(chr(13),"",$buffer);
    $Values = split($Delimiter,$buffer);

         if ( $buffer != "" )
          {
           if ( $HasHeader == TRUE && $HeaderParsed == FALSE )
            {
             if ( $DataColumns == -1 )
              {
               $ID = 1;
               foreach($Values as $key => $Value)
                { $this->SetSerieName($Value,"Serie".$ID); $ID++; }
              }
             else
              {
               $SerieName = "";
    
               foreach($DataColumns as $key => $Value)
                $this->SetSerieName($Values[$Value],"Serie".$Value);
              }
             $HeaderParsed = TRUE;
            }
           else
            {
             if ( $DataColumns == -1 )
              {
               $ID = 1;
               foreach($Values as $key => $Value)
                { $this->AddPoint(intval($Value),"Serie".$ID); $ID++; }
              }
             else
              {
               $SerieName = "";
               if ( $DataName != -1 )
                $SerieName = $Values[$DataName];
    
               foreach($DataColumns as $key => $Value)
                $this->AddPoint($Values[$Value],"Serie".$Value,$SerieName);
              }
            }
          }
        }
       fclose($handle);
      }
    }
    

    function AddPoint($Value,$Serie="Serie1",$Description="")
    {
    if (is_array($Value) && count($Value) == 1)
    $Value = $Value[0];

     $ID = 0;
     for($i=0;$i<=count($this->Data);$i++)
      { if(isset($this->Data*[$Serie])) { $ID = $i+1; } }
    
     if ( count($Value) == 1 )
      {
       $this->Data[$ID][$Serie] = $Value;
       if ( $Description != "" )
        $this->Data[$ID]["Name"] = $Description;
       elseif (!isset($this->Data[$ID]["Name"]))
        $this->Data[$ID]["Name"] = $ID;
      }
     else
      {
       foreach($Value as $key => $Val)
        {
         $this->Data[$ID][$Serie] = $Val;
         if (!isset($this->Data[$ID]["Name"]))
          $this->Data[$ID]["Name"] = $ID;
         $ID++;
        }
      }
    }
    

    function AddSerie($SerieName="Serie1")
    {
    if ( !isset($this->DataDescription["Values"]) )
    {
    $this->DataDescription["Values"][] = $SerieName;
    }
    else
    {
    $Found = FALSE;
    foreach($this->DataDescription["Values"] as $key => $Value )
    if ( $Value == $SerieName ) { $Found = TRUE; }

       if ( !$Found )
        $this->DataDescription["Values"][] = $SerieName;
      }
    }
    

    function AddAllSeries()
    {
    unset($this->DataDescription["Values"]);

     if ( isset($this->Data[0]) )
      {
       foreach($this->Data[0] as $Key => $Value)
        {
         if ( $Key != "Name" )
          $this->DataDescription["Values"][] = $Key;
        }
      }
    }
    

    function RemoveSerie($SerieName="Serie1")
    {
    if ( !isset($this->DataDescription["Values"]) )
    return(0);

     $Found = FALSE;
     foreach($this->DataDescription["Values"] as $key => $Value )
      {
       if ( $Value == $SerieName )
        unset($this->DataDescription["Values"][$key]);
      }
    }
    

    function SetAbsciseLabelSerie($SerieName = "Name")
    {
    $this->DataDescription["Position"] = $SerieName;
    }

    function SetSerieName($Name,$SerieName="Serie1")
    {
    $this->DataDescription["Description"][$SerieName] = $Name;
    }

    function removeSerieName($SerieName)
    {
    if ( isset($this->DataDescription["Description"][$SerieName]) )
    unset($this->DataDescription["Description"][$SerieName]);
    }

    function removeAllSeries()
    {
    foreach($this->DataDescription["Values"] as $Key => $Value)
    unset($this->DataDescription["Values"][$Key]);
    }

    function GetData()
    {
    return($this->Data);
    }

    function GetDataDescription()
    {
    return($this->DataDescription);
    }
    }
    ?>
    [/php]

    ...l'altro è troppo grosso e non me lo fa postare....


  • User Attivo

    Non e' che questo script ti genera solo l'immagine "example1.png" sul server e non mostra nulla a video?

    Prova a controllare.


  • User

    ...kribbio hai ragione!!!!! 😮

    Ho rinominato la png ed è stata ricreata!!!

    Marò quanto sono fesso...non ci sarei mai arrivato....grazie! 😉


  • User Attivo

    Modestamente... 😄

    ciao ciao