我想用JPGraph画出这样的东西:
我已经尝试了但是我有这样的事情:
问题:
这可以用JPGraph吗?
这是我的代码:
<?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();
?>
答案 0 :(得分:0)
您可以使用SetTickPositions()函数设置Y轴的最小值和最大值。当图形超出范围时,没有功能设置不同的颜色。但是当图形使用SetFillFromYMin()函数退出某个最小范围时,您可以填充颜色。它用预定义的颜色填充图形。