Question

here is my code :

<?php 
// content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
include("mysql _connect .php");

$code="CSC1113";
$ac_yr="2010/2011";
$sql = "SELECT results, COUNT(*) 'No_Of_grades' FROM std_results WHERE code='$code' && ac_year='$ac_yr' GROUP BY results ORDER BY results ASC";
    $result = mysql_query($sql) or die(mysql_error());
    while($ors = mysql_fetch_array($result)) {
    $grd=$ors['results'];
    switch ($grd)
{
case "A":
  $datay[1]=$ors['No_Of_grades'];
  break;
case "A+":
  $datay[0]=$ors['No_Of_grades'];
  break;
case "A-":
  $datay=$ors['No_Of_grades'];
  break;
  case "B":
  $datay[4]=$ors['No_Of_grades'];
  break;
  case "B+":
  $datay[3]=$ors['No_Of_grades'];
  break;
  case "B-":
  $datay[5]=$ors['No_Of_grades'];
  break;
 case "C":
  $datay[7]=$ors['No_Of_grades'];
  break;
  case "C+":
  $datay[6]=$ors['No_Of_grades'];
  break;
  case "C-":
  $datay[8]=$ors['No_Of_grades'];
  break;
  case "D":
  $datay[10]=$ors['No_Of_grades'];
  break;
  case "D+":
  $datay[9]=$ors['No_Of_grades'];
  break;
  case "E":
  $datay[11]=$ors['No_Of_grades'];
  break;
  case "AB":
  $datay[12]=$ors['No_Of_grades'];
  break;
  case "NE":
  $datay[13]=$ors['No_Of_grades'];
  break;
default:
  $datay[14]=$ors['No_Of_grades'];
}

    }

    //set vlaue zero for othe grades..
    for($i=0;$i<15;$i++){
        if(!isset($datay[$i])){
            $datay[$i]=0;
            }

        }


// Create the graph. These two calls are always required
$graph = new Graph(550,320,'auto');
$graph->SetScale("textlin");

//$theme_class="DefaultTheme";
//$graph->SetTheme(new $theme_class());

// set major and minor tick positions manually
$graph->yaxis->SetTickPositions(array(0,4,8,12,16,20), array(2,6,10,14,18));
$graph->SetBox(false);

//$graph->ygrid->SetColor('gray');
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels(array('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','E','AB','NE','MC'));
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);

// Create the bar plots
$b1plot = new BarPlot($datay);

// ...and add it to the graPH
$graph->Add($b1plot);


$b1plot->SetColor("white");
$b1plot->SetFillGradient("#4B0082","white",GRAD_LEFT_REFLECTION);
$b1plot->SetWidth(25);
$graph->title->Set("Bar Gradient(Left reflection)");

// Display the graph
$graph->Stroke();
?>

here jpgrpah doesn't display..error shows : JpGraph Error: 25067 Your manually specified scale and ticks is not correct. The scale seems to be too small to hold any of the specified tick marks. but I gave direct data for above $datay array.this code is working perfectly..like this

$datay[0]=2;
$datay[1]=5;
$datay[2]=1;
$datay[3]=2;
$datay[4]=0;
$datay[5]=0;
$datay[6]=3;
$datay[7]=0;
$datay[8]=3;
$datay[9]=0;
$datay[10]=1;
$datay[11]=1;
$datay[12]=0;
$datay[13]=1;
$datay[14]=1;

wht's the wrong with my code ....can't understand....help me...thanxx in advanced...

Was it helpful?

Solution

I think now that i understand you :

case "A-":
  $datay=$ors['No_Of_grades'];
  break;

should be:

case "A-":
  $datay['2']=$ors['No_Of_grades'];
  break;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top