负数时更改线条颜色

时间:2013-02-03 17:39:14

标签: php pchart

我想用Pchart制作温度线图 我需要的是正温度是红色和负蓝色 关于如何实现这种效果的任何想法?

1 个答案:

答案 0 :(得分:0)

在pChart示例中,请参阅页面[示例>面积图> drawAreaChart.threshold。 Screenshot of pGraph documentation example for drawAreaChart with threshold coloring 如果它们位于您配置的阈值内,则会对区域的某些部分(区域图)进行着色。

该示例中的代码段:

/* Draw the area chart */
$Threshold = "";
$Threshold[] = array("Min"=>0,"Max"=>5,"R"=>187,"G"=>220,"B"=>0,"Alpha"=>100);
$Threshold[] = array("Min"=>5,"Max"=>10,"R"=>240,"G"=>132,"B"=>20,"Alpha"=>100);
$Threshold[] = array("Min"=>10,"Max"=>20,"R"=>240,"G"=>91,"B"=>20,"Alpha"=>100);
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
$myPicture->drawAreaChart(array("Threshold"=>$Threshold));

在面积图中可以使用高于/低于阈值的着色。我怀疑这适用于折线图,但值得一试......

也可以用水平线表示阈值,也可以从这个例子中指出:

/* Write the thresholds */
$myPicture->drawThreshold(5,array("WriteCaption"=>TRUE,"Caption"=>"Warn Zone","Alpha"=>70,"Ticks"=>2,"R"=>0,"G"=>0,"B"=>255));
$myPicture->drawThreshold(10,array("WriteCaption"=>TRUE,"Caption"=>"Error Zone","Alpha"=>70,"Ticks"=>2,"R"=>0,"G"=>0,"B"=>255));

顺便说一句,此阈值虚线符合行(非区域)图形。