How to set min & max range in JPGraph and how to set colors for lines crossing a horizontal line?

I would like to do something similar with a JPGraph:

enter image description here

I tried, but I have something like this:

enter image description here

Problems:

  • The first problem is that I cannot set min and max for the range on Y-asix. (sometimes it works, and I don't know why)
  • And I don’t know how to set the colors for the line crossing the horizontal lines.

Is this possible with JPGraph?

Here is my code:

<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_plotline.php';        

$graph = new Graph(600,300);
$graph->SetMargin(40, 10, 10, 0);
$graph->SetScale("textlin");

$theme_class=new UniversalTheme();
$graph->SetTheme($theme_class);

$sline = new PlotLine(HORIZONTAL,30,'red'); 
$graph->Add($sline);

$sline = new PlotLine(HORIZONTAL,70,'red'); 
$graph->Add($sline);

$graph->SetScale('intlin',0,100);

$line = new LinePlot(json_decode(file_get_contents("http://data.brown.sk/data.json",true)));
$line->SetWeight(1);
$line->SetLegend("test");
$graph->Add($line);

$graph->img->SetAntiAliasing(true);

$graph->title->hide();

$graph->xaxis->Hide();

$graph->xgrid->SetLineStyle("solid");
$graph->xgrid->SetColor('#E3E3E3');

$graph->legend->hide();

$graph->Stroke();

?>
+4
source share
1 answer

SetTickPositions() Y. , , , , SetFillFromYMin(). .

0

Source: https://habr.com/ru/post/1525884/


All Articles