如何在JPGraph中显示0数据的基线?

时间:2019-04-26 11:24:35

标签: php jpgraph

我正在绘制一组可能包含null0作为数据元素的数据的条形图。

例如:[30,12,30,60,30,12,30,0,30,12,30,60,]

但是使用JPGraph我得到的输出为

output using jpgraph

我正在寻找类似的东西

expected result

如img-2中所示,对于图D,数据值为0。但单行显示为基线/基准表示。

编辑:下面是代码

require_once('jpgraph/src/jpgraph.php');
require_once('jpgraph/src/jpgraph_bar.php');
//create the graph
$graph = new Graph(512,256); //set the width and the height
$graph->SetScale("textlin"); //set the scale of the graph

$graph->img->SetMargin(40,30,40,40);

$graph->xaxis->SetTickLabels(["Sept  ","Oct  ","Nov  ","Dec  ","Jan  ","Feb  ","March  ","April  ","May  ","June  ","July  ","Aug  ","Sept  ","Oct  "]);
$graph->xaxis->scale->ticks->Set(100,5);

$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);


$data=array(30,12,30,60,30,12,30,0,30,12,30,60,); //prepare the data

// Create the bar plots and add it to the graph
$barplot = new BarPlot($data);
$graph->Add($barplot);

$path = $graph->Stroke();
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data); 

0 个答案:

没有答案