1 | initial version |
To include a horizontal line or band in jpGraph, you can use the LinePlot or AreaPlot classes. Here are the steps to create a horizontal line:
Here's an example code snippet to create a horizontal line at y=50:
$graph = new Graph(400, 300);
$line = new LinePlot(array(50));
$line->SetHoriz();
$line->SetColor('red');
$line->SetWeight(2);
$graph->Add($line);
$graph->Stroke();
And here's an example code snippet to create a horizontal band between y=20 and y=80:
$graph = new Graph(400, 300);
$area = new AreaPlot(array(20, 80));
$area->SetHoriz();
$area->SetColor('blue');
$area->SetFillColor('lightblue');
$area->SetWeight(2);
$graph->Add($area);
$graph->Stroke();
Note that the data points for the LinePlot or AreaPlot object should be in the same order as the X-axis values for your graph. If you don't have any X-axis values, you can use a range from 0 to 1 as a placeholder.