编程10000问 2019-03-27
代码如下:
  35 // DEFINE("CACHE_DIR","/tmp/jpgraph_cache/"); 
  38 // DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/"); 代码如下:
  DEFINE("CACHE_DIR","/tmp/jpgraph_cache/");' 
  DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/"); 代码如下:
  DEFINE("CACHE_DIR","c:/apache/htdocs/ jpgraph_cache/");' 
  DEFINE("TTF_DIR","c:/windows/fonts"); 代码如下:
  <?php 
  include ("jpgraph.php"); 
  include ("jpgraph_line.php"); 
  include ("jpgraph_bar.php"); 
  $connect=mysql_connect("localhost","root",""); 
  mysql_select_db("jpg",$connect); 
  $query=mysql_query("select * from test",$connect); 
  $i=0; 
  while ($array=mysql_fetch_array($query)) { 
  $l2datay[$i]=$array["number"]; 
  $i++; 
  } 
  mysql_close($connect); 
  // Create the graph. 
  $graph = new Graph(400,200,"auto"); 
  $graph->SetScale("textlin"); 
  $graph->img->SetMargin(40,130,20,40); 
  $graph->SetShadow(); 
  // Create the bar plot 
  $bplot = new BarPlot($l2datay); 
  $bplot->SetFillColor("orange"); 
  $bplot->SetLegend("Result"); 
  // Add the plots to t'he graph 
  $graph->Add($bplot); 
  $graph->title->Set("Adding a line plot to a bar graph v1"); 
  $graph->xaxis->title->Set("X-title"); 
  $graph->yaxis->title->Set("Y-title"); 
  $graph->title->SetFont(FF_FONT1,FS_BOLD); 
  $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); 
  $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); 
  //$graph->xaxis->SetTickLabels($datax); 
  //$graph->xaxis->SetTextTickInterval(2); 
  // Display the graph 
  $graph->Stroke(); 
  ?>