Как мне показать базовую линию для 0 данных в JPGraph? - PullRequest
1 голос
/ 26 апреля 2019

Я строю гистограмму для набора данных, который может содержать null или 0 в качестве элемента данных.

Например: [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); 
...