include ("/var/www/jpgraph-1.19/jpgraph.php");
include ("/var/www/jpgraph-1.19/jpgraph_line.php");
$value=array();
$value=array(23,34,6,23,56,34,0,3,34,56,3);
$max=max($value);
$graph = new Graph(720,200,"auto");
$graph->SetScale("textlin",0,$max);
$graph->img->SetMargin(40,40,40,40);
$lineplot = new LinePlot($value);
$lineplot->SetColor("red");
$graph->xaxis-> title->Set("Time(hr)--------->" );
$graph->yaxis-> title->Set("%---------------->" );
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->SetMarginColor("red");
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
//$graph->yaxis->SetLayout();
//$graph->yaxis->Pos(.4,.9,"right","right");
//$graph->legend->Pos(.01,.8,"right","center");
$lineplot->SetLegend("Value Up");
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(.5,.9,"center","right");
$graph->legend->SetFillColor("lemonchiffon2:1.3");
// To set the y axos color and font color*****************/
$graph->yaxis->SetColor("red","black");
$graph->xaxis->SetColor("red","black");
$lineplot->SetWeight(1);
$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->SetTitleMargin(30);
$graph->xaxis->SetTitleMargin(45);
$graph->SetBackgroundGradient('lemonchiffon','white',GRAD_MIDHOR,BGRAD_PLOT);
$graph->SetMarginColor('lemonchiffon2:1.3');
$lineplot->SetFillColor("chocolate1");
$graph->xaxis->scale->ticks->SetColor('black','black');
$graph->SetBox(true,'red',1);
$graph->SetShadow();
$graph->ygrid->SetColor('orange');
/**************** To add the filled circle if the value is 0 i.e if it is down*/
foreach($value as $val){
if($val == 0){
$lineplot->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot->mark->SetFillColor("black");
$lineplot->mark->SetWidth(2);
}
elseif($val < 0){
$lineplot->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot->mark->SetFillColor("red");
$lineplot->mark->SetWidth(2);
}
}
$graph->yaxis->SetTickSide(SIDE_LEFT);
$graph->xaxis->SetTickSide(SIDE_DOWN);
//$graph->xgrid->SetFill();
$graph->xgrid->Show();
$graph->Add($lineplot);
//$graph->Add($lineplot2);
$graph->Stroke();
?>
The black circle is marked for all the values in the array if the value is 0.
I just want the black filled circle if only the value is 0 and not for all the values.
But I am not understanding why it is not just plotting for the value which is 0
The output is attached figure