这是我的PHP代码:
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$data1y=array(47,80,40,116);
$data2y=array(61,30,82,105);
$data3y=array(115,50,70,93);
// Create the graph. These two calls are always required
$graph = new Graph(350,200,'auto');
$graph->SetScale("textlin");
$theme_class=new UniversalTheme;
$graph->SetTheme($theme_class);
$graph->yaxis->SetTickPositions(array(0,30,60,90,120,150), array(15,45,75,105,135));
$graph->SetBox(false);
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels(array('A','B','C','D'));
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
// Create the bar plots
$b1plot = new BarPlot($data1y);
$b2plot = new BarPlot($data2y);
$b3plot = new BarPlot($data3y);
// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($b1plot,$b2plot,$b3plot));
// ...and add it to the graPH
$graph->Add($gbplot);
$b1plot->SetColor("white");
$b1plot->SetFillColor("#cc1111");
$b2plot->SetColor("white");
$b2plot->SetFillColor("#11cccc");
$b3plot->SetColor("white");
$b3plot->SetFillColor("#1111cc");
$graph->title->Set("Bar Plots");
// Display the graph
$graph->Stroke();
这是我的HTML:
屏幕上没有错误消息。浏览器的控制台也是空的。
可能有什么不对?我需要设置一些东西吗?
我试过这个链接:jpgraph doesn't work但没有成功。
答案 0 :(得分:1)
确保你至少有一个jpgraph的“安装”,这是你root
中需要的(至少):
-chart.php
-jpgraph
-fonts
-FF_FONT0.gdf
-FF_FONT0-Bold.gdf
-FF_FONT1.gdf
-FF_FONT1-Bold.gdf
-FF_FONT2.gdf
-FF_FONT2-Bold.gdf
-themes
-UniversalTheme.class.php
-gd_image.inc.php
-imageSmoothArc.php
-jpg-config.inc.php
-jpgraph.php
-jpgraph_bar.php
-jpgraph_errhandler.inc.php
-jpgraph_gradient.php
-jpgraph_legend.inc.php
-jpgraph_plotband.php
-jpgraph_rgb.inc.php
-jpgraph_text.inc.php
-jpgraph_theme.inc.php
-jpgraph_ttf.inc.php
也一定要启用GD library
,如果您无法访问文件系统,请在USE_CACHE
中关闭jpg-config
。
正如我在评论中写的那样,你的代码在默认安装下工作正常(意味着我只提取了上面列出的文件,将你的代码添加到root中的chart.php中,我得到4组中3个条形图像..
编辑:此外,请检查其文档中的troubleshooting tips和this SO topic,这也与您的问题相关