HuasoFoundries/jpgraph

Band disappear

mila76 opened this issue · 6 comments

use Amenadiel\JpGraph\Graph;
use Amenadiel\JpGraph\Plot;

$lineData = array(
0 => 2.176,
1 => 2.17,
2 => 2.185,
3 => 2.195,
4 => 2.171,
5 => 2.168,
6 => 2.168,
7 => 2.163,
8 => 2.149,
9 => 2.189,
10 => 2.192,
11 => 2.17,
12 => 2.146,
13 => 2.169,
14 => 2.176,
15 => 2.174,
16 => 2.183,
17 => 2.176,
18 => 2.159,
19 => 2.194,
);

$graph = new Graph\Graph(800, 440, 'auto');
$graph->img->SetMargin(50, 20, 20, 40);
$graph->SetScale('textlin', 2.11, 2.29);
$graph->yaxis->scale->SetGrace(2, 2);

$p1 = new Plot\LinePlot($lineData);

$graph->AddBand(new Plot\PlotBand(HORIZONTAL, 2, 2.25, 'max', '#5C9BF9'));
$graph->AddBand(new Plot\PlotBand(HORIZONTAL, 1, 'min', 2.15, '#5C9BF9'));

$graph->Add($p1);
$graph->Stroke();

The PlotBand dont work anymore... i can see only a fraction of the upper and none of the bottom
Original version work as expected

I try to investigate this bug bot for now no luck... thinks some "z order" broblem

** Update: I try original jpgraph 4.2.0 and have the same bug... i figured out only now my code use old 3.0.7 (and work correctly)

** Update2: adding $graph->ygrid->Show(false); seem fix the problem

I figured out the problem
In 3.0.7 in the Stroke of the Graph the call of StrokeBands is before the call of grid stroke
On 4.2 no

I'm not sure what implications this fix have....

The constructor of the plotband accepts two additional parameters: $weight and $depth. By default the $depth is set to the constant DEPTH_BACK (0) if you instead set it as DEPTH_FRONT (1) the plotband will be drawn over the graph plot.

plotband

i agree what you say... if want band front of the line graph
But who wants band behind the default gray/white y grid? is alway invisible

Don't look at me, I'm just the guy who ported the old jpgraph to psr4. There's a lot in there that makes no sense.

I'm not blaming you off course :)
But a "bug is a bug"... maybe something can be fixed on your repository

So, what should we do? Set the band to be on top by default? It does make sense