<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Uncommon Avenue</title>
	
	<link>http://uncommonavenue.com</link>
	<description>A journey into the uncommon</description>
	<lastBuildDate>Wed, 05 Oct 2011 02:15:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/uncommonavenuecom" /><feedburner:info uri="uncommonavenuecom" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Adding grid lines using javascript</title>
		<link>http://feedproxy.google.com/~r/uncommonavenuecom/~3/jCkbqN6nx20/</link>
		<comments>http://uncommonavenue.com/?p=11#comments</comments>
		<pubDate>Wed, 05 Oct 2011 01:53:44 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://uncommonavenue.com/?p=11</guid>
		<description><![CDATA[Grid lines have all sorts of uses.  They can help layout a site, be used as a decoration, or the background of a graph or chart.  The easiest way to make a grid is use a background image.  That’s simple enough, but a background image can’t easily be resized. That’s the advantage of drawing the [...]]]></description>
			<content:encoded><![CDATA[<p style="font-size: 1.5em; margin: 1em;">Grid lines have all sorts of uses.  They can help layout a site, be used as a decoration, or the background of a graph or chart.  The easiest way to make a grid is use a background image.  That’s simple enough, but a background image can’t easily be resized. That’s the advantage of drawing the grid in Javascript.</p>
<p style="font-size: 1.5em; margin: 1em;">In order to draw the grid lines we’re going to use the css extensions, “-moz-element” and “-webkit-canvas”.  These extensions allow us to use a canvas as the background image of any element on the page.  The canvas allows us to draw anything we want, in this case, grid lines.</p>
<p style="font-size: 1.5em; margin: 1em; font-weight: bold;">NOTE: this example only works in Firefox Chrome and Safari.</p>
<p style="font-size: 1.5em; margin: 1em;">The easiest way to draw grid lines is to draw 2 lines and set the background to repeat.  What do I mean?</p>
<p style="font-size: 1.5em; margin: 1em;">If you take this image of 2 lines and repeat it you get a grid.</p>
<p><a style="text-align:center; display:block;" href="http://uncommonavenue.com/wp-content/uploads/2011/10/grid-line-repeat-example.png"><img class="aligncenter size-full wp-image-19" title="grid line repeat example" src="http://uncommonavenue.com/wp-content/uploads/2011/10/grid-line-repeat-example.png" alt="" width="720" height="388" /></a></p>
<p style="font-size: 1.5em; margin: 1em;">If the top and left sides not being filled are a problem then you can add a border-top and border-left to the element to compensate.  Another solution is to add an offset to the background css of the grid width -1.  So if the grid is 32px by 32px you can add:</p>
<p style="margin: 2em;">[css]background-position: -31px -31px;[/css]</p>
<p style="font-size: 1.5em; margin: 1em;">This will leave the right and bottom sides open however.  The most sensible for a graph or chart would</p>
<p style="margin: 2em;">[css]background-position: 0px -31px;[/css]</p>
<p style="font-size: 1.5em; margin: 1em;">Assuming that you have your axes on the left and bottom.</p>
<p>&nbsp;</p>
<p style="font-size: 1.5em; margin: 1em;">Now to the code!</p>
<p><iframe style="width: 100%; height: 700px;" src="http://jsfiddle.net/HyperionsShadow/dzGvx/embedded/" width="320" height="660"></iframe></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/uncommonavenuecom?a=jCkbqN6nx20:TK0BIJaG3uU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/uncommonavenuecom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/uncommonavenuecom?a=jCkbqN6nx20:TK0BIJaG3uU:-BTjWOF_DHI"><img src="http://feeds.feedburner.com/~ff/uncommonavenuecom?i=jCkbqN6nx20:TK0BIJaG3uU:-BTjWOF_DHI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/uncommonavenuecom?a=jCkbqN6nx20:TK0BIJaG3uU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/uncommonavenuecom?i=jCkbqN6nx20:TK0BIJaG3uU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/uncommonavenuecom?a=jCkbqN6nx20:TK0BIJaG3uU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/uncommonavenuecom?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/uncommonavenuecom?a=jCkbqN6nx20:TK0BIJaG3uU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/uncommonavenuecom?i=jCkbqN6nx20:TK0BIJaG3uU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/uncommonavenuecom?a=jCkbqN6nx20:TK0BIJaG3uU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/uncommonavenuecom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/uncommonavenuecom?a=jCkbqN6nx20:TK0BIJaG3uU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/uncommonavenuecom?i=jCkbqN6nx20:TK0BIJaG3uU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/uncommonavenuecom?a=jCkbqN6nx20:TK0BIJaG3uU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/uncommonavenuecom?i=jCkbqN6nx20:TK0BIJaG3uU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/uncommonavenuecom?a=jCkbqN6nx20:TK0BIJaG3uU:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/uncommonavenuecom?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/uncommonavenuecom/~4/jCkbqN6nx20" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://uncommonavenue.com/?feed=rss2&amp;p=11</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://uncommonavenue.com/?p=11</feedburner:origLink></item>
	</channel>
</rss>

