【发布时间】:2014-03-05 14:55:20
【问题描述】:
我想用 JPGraph 画出这样的东西:
我试过了,但我得到了这样的东西:
问题:
- 第一个问题是我无法在 Y 轴上设置最小值和最大值。 (这有时有效,但我不知道为什么)
- 而且我不知道如何为穿过水平线的线设置颜色。
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();
?>
【问题讨论】: