English 中文(简体)
3D graphs using pChart
原标题:

Is there a way to draw a 3D Bar Graph using the pChart library in PHP?

I m able to draw a 3D Pie graph but not a line graph.

My code looks as follows

    //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" />
问题回答

youll need a rework for a pChart.class in drawStackedBarGraph or drawBarGraph in actually-draw part:

                          $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);

and add some u-func:

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




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签