【发布时间】:2016-12-17 13:34:21
【问题描述】:
我是使用 jpgraph 的新手,我有一个条形图,我希望它根据每个条的值具有不同的颜色,
所以在百分比的情况下,当柱值为< 80时,我希望它是一个红柱,当它是>= 80 && <85时,我希望它是一个黄柱 strong> 当它是>= 85 时,一个绿条
我所能做的就是为图中的所有条形提供相似的颜色
这里是代码,如果你能帮我添加条件格式,请帮忙!
$datay=array(90,82,70,30,100,85);
// Create the graph. These two calls are always required
$graph = new Graph(300,200,"auto");
$graph->SetScale("textlin");
// Add a drop shadow
$graph->SetShadow();
// Adjust the margin a bit to make more room for titles
$graph->img->SetMargin(40,30,20,40);
// Create a bar pot
$bplot = new BarPlot($datay);
// Adjust fill color
$graph->Add($bplot);
$bplot->value->Show();
/* I tried to add if statement here but the pic won't render */
$bplot->SetFillColor('orange');
// Display the graph
$graph->Stroke();
【问题讨论】: