i am using these codes to generate linear graph from mysql...

<?php
ini_set('display_errors', 1); 
error_reporting(E_ALL); 
session_start();
//if(isset($_SESSION['user'])) {      
   //function generateGraph(){

      include('connectsml.php');
      //include('jpgraph/src/jpgraph.php');   
      //include('jpgraph/src/jpgraph_bar.php');
      include ('jpgraph/src/jpgraph_line.php');
      include ('jpgraph/src/jpgraph_log.php');

      //dapatkan nama ladang;
      $ldgcode=$_POST['ldgcode'];
      $year=$_POST['year'];      

      $sqllsblock="select * from ladang where ldgcode='$ldgcode' order by block";
      $reslsblock=mysql_query($sqllsblock);
      if ($rowlsblock=mysql_fetch_array($reslsblock)){
      do{
      $data[] = $result['yield'];
      $y2data[] = $result['month'];
      }while ($rowlsblock=mysql_fetch_array($reslblock));
      }


      $graph = new Graph(700,300);
      $graph->SetScale("textlin");
      $graph->img->SetMargin(40,40,20,70);
      $graph->AdjBackgroundImage(0.4,0.7,-1); 
      $graph->SetShadow();

      //titles n layout
      $graph ->title->Set("Penghasilan BTS Mengikut Blok Dalam Setahun" );
      $graph ->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
      $graph ->xaxis->title->Set("Bulan");
      $graph ->xgrid->Show(true,false);
      $graph ->xaxis->SetTextTickInterval(3);
      $graph ->yaxis->SetColor("blue");
      $graph ->yaxis->SetWeight("1");
      $graph ->yaxis->title->Set("Penghasilan");
      $graph ->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
      $graph ->yaxis->scale->ticks->SupressFirst();
      $graph ->SetShadow();
      $graph ->legend->SetLayout(LEGEND_HOR);
      $graph ->legend->Pos(.5,.90,"center","center");
      $graph ->ygrid->Show(true,false);

      //Create linear graph for weight
      $lineplot = new LinePlot($data);
      $lineplot ->SetColor("blue");
      $lineplot ->mark->SetColor("blue");
      $lineplot ->SetWeight("2");
      $lineplot ->SetLegend("Penghasilan");

      //Create linear graph for month
      $graph ->SetY2Scale("lin");
      $lineplot2 = new LinePlot($y2data);
      $lineplot2->SetColor("red");
      $lineplot2 ->mark->SetColor("red");
      $lineplot2->SetWeight(2);
      $lineplot2 ->SetLegend("Bulan");
      $graph ->y2axis->SetColor("red");
      $graph ->y2grid->Show(true,false);

      //Draw the graphs
      $graph->Add($lineplot);
      $graph->title->Set("Penghasilan BTS Mengikut Blok Dalam Setahun");
      $graph->xaxis->title->Set("Bulan");
      $graph->yaxis->title->Set("Penghasilan");
      $graph->Stroke();
      ?>

but i got this error:

Fatal error: Class 'Plot' not found in C:\xampp\htdocs\public\jpgraph\src\jpgraph_line.php on line 25

anyone can help me?

Recommended Answers

All 2 Replies

In the future, you should enclose your code in code tags. It makes it more usable?

I don't know if it is causing your problem or not but was there a reason for commenting out:

include ('jpgraph/src/jpgraph.php');

In the examples that I looked at, it was always included along with an include for the specific graph type that is to be displayed (in this case jpgraph_line.php). I'd try removing the // and see if that helps.

sorry about the codes tag.i'm new here :) thank you so much for reminding me and for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.