<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flav36rs &#187; gdlib</title>
	<atom:link href="http://flav36rs.com/tag/gdlib/feed/" rel="self" type="application/rss+xml" />
	<link>http://flav36rs.com</link>
	<description>Just another technical blog</description>
	<lastBuildDate>Mon, 12 Sep 2011 16:56:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Simple PHP Sparklines</title>
		<link>http://flav36rs.com/2008/04/12/simple-php-sparklines/</link>
		<comments>http://flav36rs.com/2008/04/12/simple-php-sparklines/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 22:16:24 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[gdlib]]></category>
		<category><![CDATA[sparkline]]></category>

		<guid isPermaLink="false">http://sha.re.it/?p=15</guid>
		<description><![CDATA[Whilst designing a new layout for one of my current projects, I wanted to be able to provide the end user with the ability to quickly scan over a series of statistics. The main page should act as overview of &#8230; <a href="http://flav36rs.com/2008/04/12/simple-php-sparklines/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Whilst designing a new layout for one of my current projects, I wanted to be able to provide the end user with the ability to quickly scan over a series of statistics.</p>
<p>The main page should act as overview of everything that is going on, therefore I wanted to avoid overcrowding it with lots of large graphs and instead simply show the basic trends.</p>
<p>A few months back I came across an implementation of <a title="Sparkline From Wikipedia, the free encyclopedia" href="http://en.wikipedia.org/wiki/Sparkline" target="_blank">Sparklines</a> &#8211; data-intense, design-simple, word-sized graphics &#8211; which are often used to demonstrate stock market activity in a simple visual graphic.</p>
<p>I was just going to use a pre-made script from the many already available, but instead decided to knock one up myself and created a small <a title="PHP Class Source Code" href="http://sha.re.it/wp-content/examples/sparkline/sparkline.class.phps" target="_blank">PHP Class</a> to generate and output a sparkline image using the GD Library.</p>
<p>To create a sparkline I can now simply include the class and then initiate it in a variation of the following:</p>
<pre lang="php">$sparkline = new Sparkline();
$sparkline-&gt;data = Array(3,38,2,8, ... ,38,13,4,23);
$sparkline-&gt;output(); // Display image</pre>
<p>This PNG image is generated and output to the browser:</p>
<p style="text-align: center;"><img src="http://sha.re.it/wp-content/examples/sparkline/example1.php" alt="Example Sparkline" width="120" height="40" /></p>
<p style="text-align: left;">A number of other setup options are available to customise the output further:</p>
<pre lang="php">$sparkline-&gt;bg = '#000000'; // Background colour
$sparkline-&gt;width = 150;
$sparkline-&gt;height = 50;
$sparkline-&gt;line = '#336699'; // Line colour
$sparkline-&gt;points = '#333333'; // Start &amp; end points
$sparkline-&gt;thickness = 2; // Line thickness
$sparkline-&gt;scale = 5; // Anti-aliasing scale size
$sparkline-&gt;output('saved/test.png', true); // Save to location and display</pre>
<p style="text-align: center;"><img src="http://sha.re.it/wp-content/examples/sparkline/example2.php" alt="Customised Sparkline" width="180" height="60" /></p>
<p style="text-align: left;">All colours must be provided in hexadecimal format and if you are attempting to save the image the destination location must be writeable by Apache.</p>
<p style="text-align: left;">The <a title="PHP Class Source Code" href="http://sha.re.it/wp-content/examples/sparkline/sparkline.class.phps" target="_blank">Sparkline PHP Class source code</a> is available for anyone to use as they may like, although I must confess it hasn&#8217;t been fully tested as yet!</p>
]]></content:encoded>
			<wfw:commentRss>http://flav36rs.com/2008/04/12/simple-php-sparklines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

