我有这个JPGraph(有正确的数据):
// Create the graph. These two calls are always required
$graph = new Graph(640,350,"auto");
$graph->SetScale("textlin");
$graph->SetY2Scale("lin",0,100);
// Create the bar graph
$bplot1 = new BarPlot($datay);
$bplot1->SetFillGradient("darkolivegreen1","darkolivegreen4",GRAD_VERT);
$bplot1->SetWeight(0);
$graph->Add($bplot1);
// Create the line graph
$lplot = new LinePlot($datay2);
$lplot->SetBarCenter();
$lplot->SetStepStyle();
$graph->AddY2($lplot);
// Display the graph
$graph->Stroke();
这工作正常(至少它显示了正确的数据),但我的问题是 Y2 数据在条形后面。我希望 Y2 数据在前面,这样数据就可以以浅不透明度显示,我可以看到它有多少百分比。
我尝试重新排列代码,使 AddY2 排在第一位或最后,甚至混合了它,但仍然是一样的 - 总是在酒吧后面。
有人对此有任何见解吗?
如果这不可行,那么还有什么替代方案 - 任何其他免费的图形工具都可以像JPGraph一样好(我使用CentOS和PHP)?
如果我了解您希望实现的目标...尝试翻转 Y 刻度。
$graph->Add($bplot1);
到$graph->AddY2($bplot1);
和
$graph->AddY2($lplot);
变得$graph->Add($lplot);
编辑:
因为我误解了...添加$graph->SetY2OrderBack(false);
会将 Y2 置于 Y1 的前景中。来源: docs/classref/Graph.html#_GRAPH_SETY2ORDERBACK