<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to make a progress/goal (thermometer-like) bar graph with PHP</title>
	<atom:link href="http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/</link>
	<description></description>
	<lastBuildDate>Tue, 16 Mar 2010 19:26:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Brian</title>
		<link>http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/comment-page-1/#comment-599060</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Mon, 29 Sep 2008 21:47:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/#comment-599060</guid>
		<description>Sorry, the last post cut it short: here&#039;s the important part:

/*vertical bar*/
	//imagefilledrectangle($im, 0, $vert_fill, $width, $height, $fg);
	
	/*horizontal bar*/
	imagefilledrectangle($im, 0, 0, $hor_fill, $height, $fg);
	
	$percent_num = round(($current/$goal)*100);
	if($percent_num &gt;= 10 &amp;&amp; $percent_num &lt; 100)
		$middle = $width/2-8;
	elseif($percent_num &lt; 10)
		$middle = $width/2-5;
	elseif($percent_num == 100)
		$middle = $width/2-12;
		
	/*vertical text*/
	//imagestring($im, 3, 3, 1,  $percent, $text_color);
	
	/*horizontal text*/
	imagestring($im, 3, $middle, 1,  $percent, $text_color);</description>
		<content:encoded><![CDATA[<p>Sorry, the last post cut it short: here&#039;s the important part:</p>
<p>/*vertical bar*/<br />
	//imagefilledrectangle($im, 0, $vert_fill, $width, $height, $fg);</p>
<p>	/*horizontal bar*/<br />
	imagefilledrectangle($im, 0, 0, $hor_fill, $height, $fg);</p>
<p>	$percent_num = round(($current/$goal)*100);<br />
	if($percent_num &gt;= 10 &amp;&amp; $percent_num &lt; 100)<br />
		$middle = $width/2-8;<br />
	elseif($percent_num &lt; 10)<br />
		$middle = $width/2-5;<br />
	elseif($percent_num == 100)<br />
		$middle = $width/2-12;</p>
<p>	/*vertical text*/<br />
	//imagestring($im, 3, 3, 1,  $percent, $text_color);</p>
<p>	/*horizontal text*/<br />
	imagestring($im, 3, $middle, 1,  $percent, $text_color);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/comment-page-1/#comment-599059</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Mon, 29 Sep 2008 21:46:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/#comment-599059</guid>
		<description>Here&#039;s the real Horizontal fix (the vertical bar is left in but commented out for safe switching)

 $goal) {
		$current = 100;
		$percent= &quot;100%!&quot;;
	} else if ($current == &quot;&quot; &#124;&#124; $current == &quot;0&quot;) {
		$percent = &quot;0%&quot;;
	} else {
	 $percent = round(($current/$goal)*100) . &quot;%&quot;;
	}
	
	$im = @imagecreate($width,$height)
		or die(&quot;Cannot Initialize new GD image stream&quot;);
		
	$bg = ImageColorAllocate($im,200,200,200); // grey
	$fg = ImageColorAllocate($im,0,150,255); //blue
	$text_color = imagecolorallocate($im, 70, 70, 70); //dark grey
	
	$vert_fill = height - (($current/$goal)*$height);
	$hor_fill = (($current/$goal)*$width);
	
	/*vertical bar*/
	//imagefilledrectangle($im, 0, $vert_fill, $width, $height, $fg);
	
	/*horizontal bar*/
	imagefilledrectangle($im, 0, 0, $hor_fill, $height, $fg);
	
	$percent_num = round(($current/$goal)*100);
	if($percent_num &gt;= 10 &amp;&amp; $percent_num &lt; 100)
		$middle = $width/2-8;
	elseif($percent_num </description>
		<content:encoded><![CDATA[<p>Here&#039;s the real Horizontal fix (the vertical bar is left in but commented out for safe switching)</p>
<p> $goal) {<br />
		$current = 100;<br />
		$percent= &#034;100%!&#034;;<br />
	} else if ($current == &#034;&#034; || $current == &#034;0&#034;) {<br />
		$percent = &#034;0%&#034;;<br />
	} else {<br />
	 $percent = round(($current/$goal)*100) . &#034;%&#034;;<br />
	}</p>
<p>	$im = @imagecreate($width,$height)<br />
		or die(&#034;Cannot Initialize new GD image stream&#034;);</p>
<p>	$bg = ImageColorAllocate($im,200,200,200); // grey<br />
	$fg = ImageColorAllocate($im,0,150,255); //blue<br />
	$text_color = imagecolorallocate($im, 70, 70, 70); //dark grey</p>
<p>	$vert_fill = height &#8211; (($current/$goal)*$height);<br />
	$hor_fill = (($current/$goal)*$width);</p>
<p>	/*vertical bar*/<br />
	//imagefilledrectangle($im, 0, $vert_fill, $width, $height, $fg);</p>
<p>	/*horizontal bar*/<br />
	imagefilledrectangle($im, 0, 0, $hor_fill, $height, $fg);</p>
<p>	$percent_num = round(($current/$goal)*100);<br />
	if($percent_num &gt;= 10 &amp;&amp; $percent_num &lt; 100)<br />
		$middle = $width/2-8;<br />
	elseif($percent_num</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martman</title>
		<link>http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/comment-page-1/#comment-586152</link>
		<dc:creator>Martman</dc:creator>
		<pubDate>Tue, 22 Jul 2008 15:53:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/#comment-586152</guid>
		<description>Hi, first of all great site, has helped me out on several occasions, just wondering if anyone could help me with a change to this php code.

instead of letting the php fill the completed (red) box, can the php be told to fill it up with a hosted image.

something along the lines of below is what i&#039;m on about

$fg = ImageLink($im,&quot;graph_fill.png&quot;);

any help would be appreiciated</description>
		<content:encoded><![CDATA[<p>Hi, first of all great site, has helped me out on several occasions, just wondering if anyone could help me with a change to this php code.</p>
<p>instead of letting the php fill the completed (red) box, can the php be told to fill it up with a hosted image.</p>
<p>something along the lines of below is what i&#039;m on about</p>
<p>$fg = ImageLink($im,&#034;graph_fill.png&#034;);</p>
<p>any help would be appreiciated</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dmpHOME</title>
		<link>http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/comment-page-1/#comment-585941</link>
		<dc:creator>dmpHOME</dc:creator>
		<pubDate>Mon, 21 Jul 2008 17:55:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/#comment-585941</guid>
		<description>how can I do something like that? http://www.btarg.com.ar/tracker/pic/chanchito.php

thanks!</description>
		<content:encoded><![CDATA[<p>how can I do something like that? <a href="http://www.btarg.com.ar/tracker/pic/chanchito.php" rel="nofollow">http://www.btarg.com.ar/tracker/pic/chanchito.php</a></p>
<p>thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Music Critic</title>
		<link>http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/comment-page-1/#comment-576823</link>
		<dc:creator>Music Critic</dc:creator>
		<pubDate>Tue, 03 Jun 2008 21:18:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/#comment-576823</guid>
		<description>That is very cool. I can think of a number of things to use this bar graph for. Thanks.</description>
		<content:encoded><![CDATA[<p>That is very cool. I can think of a number of things to use this bar graph for. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Klick</title>
		<link>http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/comment-page-1/#comment-574590</link>
		<dc:creator>Nicholas Klick</dc:creator>
		<pubDate>Wed, 21 May 2008 03:51:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/#comment-574590</guid>
		<description>I had to replace my tags with parens I guess

echo&quot;(div class=\&quot;impactTitle\&quot;)$title (/div)(br/)(br/)&quot;;
  echo&quot;(div class=\&quot;graph\&quot;)(div class=\&quot;bar\&quot; style=\&quot;width: $percentage%\&quot;)$percentage%(/div)(/div)(div class=\&quot;zero\&quot;)0(/div)(div class=\&quot;graphNum\&quot;)$target(/div)(br/)(br/)&quot;;
  echo&quot;(div class=\&quot;descrip\&quot;)$descrip(/div)(br/)(br/)(br/)(br/)&quot;;</description>
		<content:encoded><![CDATA[<p>I had to replace my tags with parens I guess</p>
<p>echo&#034;(div class=\&#034;impactTitle\&#034;)$title (/div)(br/)(br/)&#034;;<br />
  echo&#034;(div class=\&#034;graph\&#034;)(div class=\&#034;bar\&#034; style=\&#034;width: $percentage%\&#034;)$percentage%(/div)(/div)(div class=\&#034;zero\&#034;)0(/div)(div class=\&#034;graphNum\&#034;)$target(/div)(br/)(br/)&#034;;<br />
  echo&#034;(div class=\&#034;descrip\&#034;)$descrip(/div)(br/)(br/)(br/)(br/)&#034;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Klick</title>
		<link>http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/comment-page-1/#comment-574589</link>
		<dc:creator>Nicholas Klick</dc:creator>
		<pubDate>Wed, 21 May 2008 03:47:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/#comment-574589</guid>
		<description>Jennifer,

This is a nice method that I had not seen before. I like the use of straight php code for the bar graph.

We recently created a goal graph but used a horizontally tiled image (using nested div tags), overlaid on a BG-image. The width of the interior div inherits the percentage towards the goal. 

You can view it here: http://www.fightwithfact.com/impact.php

We loop thru the goal data from our database and then print it out:


 for ($i = 0; $i records); $i++)
 {

  $title = $goalListObj-&gt;records[$i]-&gt;title;
  $descrip = $goalListObj-&gt;records[$i]-&gt;description;
  $actual = $goalListObj-&gt;records[$i]-&gt;actualNumber;
  $target = $goalListObj-&gt;records[$i]-&gt;targetNumber;
  $percentage = round(($actual / $target) * 100) ;
  
  echo&quot;$title &quot;;
  echo&quot;$percentage%0
$target&quot;;
  echo&quot;$descrip&quot;;</description>
		<content:encoded><![CDATA[<p>Jennifer,</p>
<p>This is a nice method that I had not seen before. I like the use of straight php code for the bar graph.</p>
<p>We recently created a goal graph but used a horizontally tiled image (using nested div tags), overlaid on a BG-image. The width of the interior div inherits the percentage towards the goal. </p>
<p>You can view it here: <a href="http://www.fightwithfact.com/impact.php" rel="nofollow">http://www.fightwithfact.com/impact.php</a></p>
<p>We loop thru the goal data from our database and then print it out:</p>
<p> for ($i = 0; $i records); $i++)<br />
 {</p>
<p>  $title = $goalListObj-&gt;records[$i]-&gt;title;<br />
  $descrip = $goalListObj-&gt;records[$i]-&gt;description;<br />
  $actual = $goalListObj-&gt;records[$i]-&gt;actualNumber;<br />
  $target = $goalListObj-&gt;records[$i]-&gt;targetNumber;<br />
  $percentage = round(($actual / $target) * 100) ;</p>
<p>  echo&#034;$title &#034;;<br />
  echo&#034;$percentage%0<br />
$target&#034;;<br />
  echo&#034;$descrip&#034;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jennifer</title>
		<link>http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/comment-page-1/#comment-571908</link>
		<dc:creator>Jennifer</dc:creator>
		<pubDate>Tue, 06 May 2008 17:19:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/#comment-571908</guid>
		<description>@Valerie
I believe you need to change the script with this line:
&lt;strong&gt;$fill = $height-(($current/$goal)*$height);&lt;/strong&gt;
Instead of having the fill be calculated on the HEIGHT - you want it calculated to the WIDTH - so changing $height to $width where it appears in that line should do the trick... ?</description>
		<content:encoded><![CDATA[<p>@Valerie<br />
I believe you need to change the script with this line:<br />
<strong>$fill = $height-(($current/$goal)*$height);</strong><br />
Instead of having the fill be calculated on the HEIGHT &#8211; you want it calculated to the WIDTH &#8211; so changing $height to $width where it appears in that line should do the trick&#8230; ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valerie</title>
		<link>http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/comment-page-1/#comment-571897</link>
		<dc:creator>Valerie</dc:creator>
		<pubDate>Tue, 06 May 2008 16:55:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/#comment-571897</guid>
		<description>hey, great tutorial. :)

was wondering how easy it would be to change it to be a horizontal bar graph, a bit like a ticker?</description>
		<content:encoded><![CDATA[<p>hey, great tutorial. <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>was wondering how easy it would be to change it to be a horizontal bar graph, a bit like a ticker?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aiko</title>
		<link>http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/comment-page-1/#comment-552299</link>
		<dc:creator>Aiko</dc:creator>
		<pubDate>Mon, 03 Mar 2008 21:47:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/#comment-552299</guid>
		<description>Great script ! Just what I was looking for. I&#039;m using it on my sidebar and use PHP to specify the current value so it&#039;s fully automated now.

Thanks for sharing!</description>
		<content:encoded><![CDATA[<p>Great script ! Just what I was looking for. I&#039;m using it on my sidebar and use PHP to specify the current value so it&#039;s fully automated now.</p>
<p>Thanks for sharing!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.257 seconds -->
