2009-11-11 4 views
0

Existe-t-il un moyen de dessiner un graphique à barres 3D à l'aide de la bibliothèque pChart en PHP?Graphes 3D utilisant pChart

Je suis capable de dessiner un graphique 3D Pie mais pas un graphique linéaire.

Mon code se présente comme suit

//The 3D bar graph 
    # // Dataset definition 
    $DataSet = new pData; 
    // $DataSet->AddPoint(array(10,40,30,20,30,30,20,10,10,70,40),"Serie1"); 
    $DataSet->AddPoint(52,"Serie2","January 2009"); 
    $DataSet->AddPoint(94,"Serie2","February 2009"); 
    $DataSet->AddPoint(44,"Serie2","March 2009"); 
    $DataSet->AddPoint(65,"Serie2","April 2009"); 
    $DataSet->AddPoint(38,"Serie2","May 2009"); 
    $DataSet->AddPoint(43,"Serie2","August 2009"); 
    $DataSet->AddPoint(34,"Serie2","September 2009"); 

    $DataSet->AddAllSeries(); 
    $DataSet->SetAbsciseLabelSerie(); 
    $DataSet->SetSerieName("Months","Serie2"); 
    //$DataSet->SetXAxisFormat("date"); 
    // $DataSet->SetXAxisUnit("months"); 

    // Initialise the graph 
    $Test = new pChart(800,240); 
    $Test->setFixedScale(0,100); 
    $Test->loadColorPalette('pChart.1.26e/color/tones-4.txt',','); 
    $Test->setFontProperties("pChart.1.26e/Fonts/FreeSans.ttf",8); 
    $Test->setGraphArea(50,30,680,200); 
    $Test->drawFilledRoundedRectangle(7,7,693,223,5,255,255,255); 
    $Test->drawRectangle(10,5,695,225,169,169,169); 
    $Test->drawGraphArea(255,255,255,TRUE); 
    $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),10,150,150,150,TRUE,0,2,TRUE);  
    $Test->drawGrid(10,TRUE,230,230,230,50); 

    $Test->setFontProperties("pChart.1.26e/Fonts/FreeSansBold.ttf",15); 
    $Test->drawTitle(50,22,"Clicks Per Month",50,50,50,585); 

    // Draw the 0 line 
    $Test->setFontProperties("pChart.1.26e/Fonts/FreeSans.ttf",6); 
    $Test->drawTreshold(0,143,55,72,TRUE,TRUE); 

    //Monthly Target 
    $Test->setFontProperties("pChart.1.26e/Fonts/FreeSansBold.ttf",10); 
    $Test->drawTreshold(40,143,55,72,TRUE,TRUE,4); 


    // Draw the bar graph 
    $Test->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),TRUE); 
    // Finish the graph 
    $Test->setFontProperties("pChart.1.26e/Fonts/FreeSans.ttf",8); 
    // $Test->drawLegend(596,150,$DataSet->GetDataDescription(),255,255,255); 

    $Test->Render("generated/example12.png"); 
?><img src="generated/example12.png" /> 

Répondre

0

vous aurez besoin d'une reprise pour une pChart.class dans drawStackedBarGraph ou drawBarGraph en partie en fait-tirage:

      $this->drawFilledRectangle($XPos+1,$YBottom,$XPos+$SeriesWidth-11,$YPos,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"],TRUE,$Alpha); 
     //right 
     $colorEnh=50; 
     $this->drawFilledPoly(array(
      $XPos+$SeriesWidth-10, $YBottom, 
      $XPos+$SeriesWidth-10, $YPos, 
      $XPos+$SeriesWidth-1, $YPos-10, 
      $XPos+$SeriesWidth-1, $YBottom-10, 
     ), 4, $this->Palette[$ColorID]["R"]+$colorEnh,$this->Palette[$ColorID]["G"]+$colorEnh,$this->Palette[$ColorID]["B"]+$colorEnh); 
     //top 
     $this->drawFilledPoly(array(
      $XPos+1, $YPos, 
      $XPos+10+1, $YPos-10, 
      $XPos+$SeriesWidth-1, $YPos-10, 
      $XPos+$SeriesWidth-10-1, $YPos, 
     ), 4, $this->Palette[$ColorID]["R"]-$colorEnh,$this->Palette[$ColorID]["G"]-$colorEnh,$this->Palette[$ColorID]["B"]-$colorEnh); 

et ajouter quelques u-func:

function drawFilledPoly($points, $num, $r, $g, $b){ 
imagefilledpolygon ($this->Picture , $points , $num , $this->AllocateColor($this->Picture,$r,$g,$b));} 
Questions connexes