Welcome Guest, Not a member yet? Register   Sign In
Help Me ! How To Create jpGraph In Loop
#1

[eluser]Unknown[/eluser]
I want to create graph in loop 3 but create 1 image in folder chart

Code:
<?php if( !defined('BASEPATH')) exit('No direc script access allowed');

class Test extends CI_Controller{

function __construct(){
  parent::__construct();
  require_once PUBPATH.'jpgraph/jpgraph.php';
  require_once PUBPATH.'jpgraph/jpgraph_pie.php';
  require_once PUBPATH.'jpgraph/jpgraph_pie3d.php';
}

function index(){
    
   for($i=0; $i<=3;$i++){
    
    @unlink(PUBPATH.'chart/img'.$i.'.jpg');
    
    // Some data
    $data = array(20,27,45,75,90);
    
    // Create the Pie Graph.
    $graph = new PieGraph(800,450);
    $graph->SetShadow();
    
    // Set A title for the plot
    $graph->title->Set("Pie Graph");
    $graph->title->SetFont(FF_VERDANA,FS_BOLD,18);
    $graph->title->SetColor("darkblue");
    $graph->legend->Pos(0.1,0.2);
    $graph->legend->Pos(0.9,0.9,'left','bottom');
    $graph->legend->SetLayout(LEGEND_VERT);
    
    // Create pie plot
    $p1 = new PiePlot3d($data);
    $p1->SetTheme("earth");
    $p1->SetCenter(0.4);
    $p1->SetAngle(20);
    $p1->value->SetFont(FF_ARIAL,FS_NORMAL,12);
    $p1->SetLegends(array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct"));
    
    $graph->Add($p1);
    $graph->Stroke(PUBPATH.'chart/img'.$i.'.jpg');
    
   }  
}

}

sorry i can speak english a little




Theme © iAndrew 2016 - Forum software by © MyBB