I have this JPGraph (with proper data):
// 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();
This works fine (at least it shows the correct data) but my problem is that the Y2 data is behind the bars. I want the Y2 data in front so the data can be shown with a light opacity and I can see how many percent it is.
I have tried rearranging the code so the AddY2 came first or last and even mixed it, but still the same - always behind the bars.
Anyone having any insights on this?
If this is not doable, what is the alternative then - any other free graph tools out there that works just as great as JPGraph (I use CentOS and PHP)?
If I understand what you are looking to achieve ... Try flipping around the Y scales.
$graph->Add($bplot1);
to $graph->AddY2($bplot1);
and
$graph->AddY2($lplot);
becomes $graph->Add($lplot);
EDIT:
As I misunderstood... Add $graph->SetY2OrderBack(false);
will place Y2 on the foreground of Y1.
Source: docs/classref/Graph.html#_GRAPH_SETY2ORDERBACK