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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-01-06 11:00:00 +0000
Seen: 17 times
Last updated: Apr 16 '21
What is the most efficient way to search through an acyclic graph?
How can an undirected graph be created in Gephi?
What is the way to view a DGML file that is very big in Visual Studio?
How can data be grouped by multiple columns in pandas and represented in a bar graph?
What is the longest route in a graph that has a specific direction and does not contain cycles?