1

I want to make a temperature line graph using Pchart.
What I need is that the positive temperature is Red and the negative Blue.
Any ideas on how to achieve this effect?

Michaël
  • 3,679
  • 7
  • 39
  • 64
HyperDevil
  • 2,519
  • 9
  • 38
  • 52

1 Answers1

0

In the pChart examples, see the page [Examples > Area Chart > drawAreaChart.threshold]. Screenshot of pGraph documentation example for drawAreaChart with threshold coloring This does colorizes parts of an area (in area graphs) if they are inside a threshold you configure.

Code snippet from that example:

/* 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));

This coloring above/below thresholds is possible in area graphs. I doubt this works for line graphs, but its worth a try..

Its also possible to indicate thresholds with a horizontal line, also from this example:

/* 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));

This threshold dotted line is supported in line (so non-area) graphs by the way.

Barry Staes
  • 3,890
  • 4
  • 24
  • 30