pChart 2.x forum
http://wiki.pchart.net/forum/

drawPoint
http://wiki.pchart.net/forum/viewtopic.php?f=4&t=1591
Page 1 of 1

Author:  tr0nix [ Fri Jun 24, 2011 4:21 pm ]
Post subject:  drawPoint

Another hack until the feature becomes available.. as usual no guarantee that it works for you ;-P

Add to pDraw.class.php
Code:
function drawPoint($SeriesName, $Index, $Value, $Format="") {
   $R         = isset($Format["R"]) ? $Format["R"] : 0;
   $G         = isset($Format["G"]) ? $Format["G"] : 0;
   $B         = isset($Format["B"]) ? $Format["B"] : 0;
   $Alpha      = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;

   $Data = $this->DataSet->getData();
   list($XMargin,$XDivs) = $this->scaleGetXSettings();
   if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
   $X = $this->GraphAreaX1 + $XMargin + $Index * $XStep;
   $Y =  floor($this->scaleComputeY($Value,array("AxisID"=>0)));

   $this->drawFilledCircle($X,$Y,3,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
}


Now go for it..
$this->pChart->drawPoint("Date", $index, $weekDay * 60, array("R"=>255));

=> Value must be appropriate for the AXIS format. In my case the Y-value must be given in seconds and weekDay is the day of the week. Doesn't make sense at all, but shows how it works. There's some space for improvement (like different objects or putting images directly), dunno know how I will use it in the end (I just know I need it ;-)), I may post some update to it..

Attachments:
pcharttest.png
pcharttest.png [ 60.3 KiB | Viewed 7719 times ]

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/