<?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>Michael Ewens &#187; graphs</title>
	<atom:link href="http://michaelewens.com/tag/graphs/feed/" rel="self" type="application/rss+xml" />
	<link>http://michaelewens.com</link>
	<description>Tepper School of Business, Carnegie Mellon Univ.</description>
	<lastBuildDate>Tue, 10 Jan 2012 19:00:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Graphing mysql data with PHP + jQuery</title>
		<link>http://michaelewens.com/2009/03/24/graphing-mysql-data-with-php-jquery/</link>
		<comments>http://michaelewens.com/2009/03/24/graphing-mysql-data-with-php-jquery/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 10:17:43 +0000</pubDate>
		<dc:creator>Michael Ewens</dc:creator>
				<category><![CDATA[visualization]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[graphs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://michaelewens.com/?p=222</guid>
		<description><![CDATA[For our paper on apartment rental discrimination, I maintain a database of apartment rents across 30 US cities for 1 bedrooms or studios.  Once it is in mysql (easy), I can access it with PHP and send the data to a javascript file to make simple interactive graphs. Average 1 Bedroom and Studio Rents in [...]]]></description>
			<content:encoded><![CDATA[<p>For our paper on <a href="http://michaelewens.com/research/">apartment rental discrimination</a>, I maintain a database of apartment rents across 30 US cities for 1 bedrooms or studios.  Once it is in mysql (easy), I can access it with PHP and send the data to a javascript file to make simple interactive graphs.</p>
<p><a href="http://aughta.com/paper/supply/basic.php">Average 1 Bedroom and Studio Rents in Major Cities</a> (x-axis is week number since Feb 15th)</p>
<p>Here is how it was done:</p>
<p>1.  PHP script to look through city names (I assume the database exists)</p>
<p>2.  SQL statement:</p>
<p><code>SELECT WEEKOFYEAR( DATE ) AS woy, AVG( rent ) , COUNT( * ) FROM city_counts WHERE city =  CITYNAME GROUP BY woy<br />
</code><br />
3.  For each city create a simple javascript-friendly string in PHP that looks like this:</p>
<p><code>{"LA": { label: "LA", data: [[8,1194.9206349206],[9,1261.7650969529]]},</code></p>
<p>4.  Put it all together with <a href="http://code.google.com/p/flot/">Flot</a> (<a href="http://people.iola.dk/olau/flot/examples/turning-series.html">this example</a>) + <a href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.2.js">jQuery</a>.</p>
<p>I know very little (if any) Javascript, but got this up in 15 minutes.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelewens.com/2009/03/24/graphing-mysql-data-with-php-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

