JpGraph php柱状图使用介绍

2019-04-08 23:39:32刘景俊

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

4、
  刷新页面即可看到结果
历史信息
  网络优化,300*200的图片大小大概为2K,但普通图片要比JpGraph生成的大4-5K
  支持GD1和GD2,并且JpGraph会自动探测系统安装了哪个库
  支持多种图表样式,包括常见的网状图、花柱形图、饼形图(2D和3D的都可以)等等
  支持3D透明,α混合技术
  支持超过400种的已命名颜色
  支持多种方式带背景图片的绘图
  支持生成的图表网络缓存以减轻HTTP服务器负担
  2009年9月17日:更新JpGraph 1.27.1。
  2009年4月18日:更新JpGraph 1.27和JpGraph 2.34。
  12月2日:今日有两位phpchina的朋友加入我们的翻译团队:刺猬和Deman。
  2008年6月28日:JpGraph中文站发布,虽然这是用ASP制作的网站,但并不代表站长偏爱ASP
  2008年6月15日:JpGraph 1.26发布。修复了饼形图分割片问题。也许这将是1.x发布版宣布停止更新后的最后一版2
  008年6月14日:JpGraph 2.33发布
相关文章 大家在看