pChart 2.x forum http://wiki.pchart.net/forum/ |
|
drawVerticalLine http://wiki.pchart.net/forum/viewtopic.php?f=4&t=1590 |
Page 1 of 1 |
Author: | tr0nix [ Fri Jun 24, 2011 3:58 pm ] | ||
Post subject: | drawVerticalLine | ||
Add to pDraw.class.php: Code: function drawVerticalLine($SeriesName, $Index, $Format="") { $VerticalLineR = isset($Format["VerticalLineR"]) ? $Format["VerticalLineR"] : 0; $VerticalLineG = isset($Format["VerticalLineG"]) ? $Format["VerticalLineG"] : 0; $VerticalLineB = isset($Format["VerticalLineB"]) ? $Format["VerticalLineB"] : 0; $VerticalLineAlpha = isset($Format["VerticalLineAlpha"]) ? $Format["VerticalLineAlpha"] : 40; $VerticalLineTicks = isset($Format["VerticalLineTicks"]) ? $Format["VerticalLineTicks"] : 2; $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; $this->drawLine( $X, $this->GraphAreaY1 + $Data["YMargin"], $X, $this->GraphAreaY2-$Data["YMargin"], array("R"=>$VerticalLineR,"G"=>$VerticalLineG,"B"=>$VerticalLineB,"Alpha"=>$VerticalLineAlpha,"Ticks"=>$VerticalLineTicks) ); } Now if you have an Y-Date-Axis and you want to put a vertical line on each Friday and Monday (to separate Saturday and Sunday), just go like this: Code: foreach($this->pChartData->getValues("Date") as $index => $date) { $dateSplit = preg_split ('/\./', $date); /* this depends on your format.. mine is DD.MM.YYYY */ $weekDay = date('N', mktime(0, 0, 0, (int)$dateSplit[1], (int)$dateSplit[0], (int)$dateSplit[2])); if ( $weekDay == 5 | $weekDay == 1) { $this->pChart->drawVerticalLine("Date", $index, $LabelSettings); } } Will look like attached (in combination with "BreakVoid"=>FALSE format for drawLineChart)..
|
Author: | tr0nix [ Fri Jun 24, 2011 4:11 pm ] |
Post subject: | Re: drawVerticalLine |
As soon as you can get the real x/y coordinates of the dataset-values this function can be replaced with drawline which will be more stable for sure ! |
Author: | lnf [ Sat Sep 10, 2011 2:28 pm ] |
Post subject: | Re: drawVerticalLine |
Nice looking graph! |
Author: | jean-damien [ Mon Sep 12, 2011 7:09 am ] |
Post subject: | Re: drawVerticalLine |
Hi, I've added the drawXThreshold() function in the 2.1.3 subversion. When called this function return the X position of the vertical threshold that you can re-use for further processing. (same applies for the Y thresholds an areas) JD. |
Author: | tr0nix [ Fri Oct 07, 2011 1:21 pm ] |
Post subject: | Re: drawVerticalLine |
cool! |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |