<?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>Refresh &#187; Charting</title>
	<atom:link href="http://www.refresh.dk/topic/charting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.refresh.dk</link>
	<description>Web programming for practitioners</description>
	<lastBuildDate>Sun, 02 May 2010 16:25:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Chart with selectable legend [yui demo]</title>
		<link>http://www.refresh.dk/chart-with-selectable-legend-yui-demo/</link>
		<comments>http://www.refresh.dk/chart-with-selectable-legend-yui-demo/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 14:11:53 +0000</pubDate>
		<dc:creator>Steffen Tiedemann Christensen</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.refresh.dk/chart-with-selectable-legend-yui-demo/</guid>
		<description><![CDATA[I wrote about YUI Charts the other day and I guess my conclusion was that the library is promising, but still a long way from being perfect. Today, I have been using it in a real-life setting a found that I wanted to do some stuff that&#8217;s isn&#8217;t supported out of the box in order [...]]]></description>
			<content:encoded><![CDATA[<p>I <a href="/charting-with-yui/">wrote about</a> <a href="http://yuiblog.com/blog/2007/12/04/yuii-240/">YUI Charts</a> the other day and I guess my conclusion was that the library is promising, but still a long way from being perfect. Today, I have been using it in a real-life setting a found that I wanted to do some stuff that&#8217;s isn&#8217;t supported out of the box in order to build something that looks like this:</p>
<p><a href="/examples/yuichart-with-selectable-legend" title="YUI Chart Demo Screenshot"><img src="/wordpress/wp-content/uploads/2007/12/billede-12.png" alt="YUI Chart Demo Screenshot" border="0"/></a></p>
<h3>Merge multiple dataset into one graph</h3>
<p>By default the library accepts one datasource containing a category, which is turn can have multiple values. This would be an array, which looks like this in Yahoo&#8217;s own documentation:</p>
<pre><code class="javascript">var data =
  [{ month: "January", rent: 880.00, utilities: 894.68 },
   { month: "February", rent: 880.00, utilities: 901.35 }];</code></pre>
<p>This looks great paper, but when preparing data from the database it&#8217;s requires some clever trickery to set up such a datasource. Instead, I wanted to prepare several arrays containing <tt>label</tt>/<tt>value</tt> pairs and merge them into a data source. For example:</p>
<pre><code class="javascript">var rentValues =
  [{label: "January", value:880.00},
   {label: "February", value: 880.00}];
var utillitiesValues =
  [{label: "January", value:894.68},
   {label: "February", value: 901.35}];</code></pre>
<p><a href="/examples/yuichart-with-selectable-legend">The example</a> includes a simple piece of code, which merges these two (or more) datasets into something which is edible for the YUI datasource. <i>Make sure that the <tt>label</tt> properties are the same in all datasets though. Otherwise, you&#8217;ll see strange results.</i>.</p>
<h3>Show a colorful legend</h3>
<p>Even though you&#8217;ll actually be sending all the required information to the chart library, it won&#8217;t build a chart legend for you. Which is bad. Instead, the documentation shows how to set up something similar in HTML. In this case, I wanted to allow selection and de-selection of items on the chart and have the visualization scaled accordingly.</p>
<p>In the example I&#8217;m using the same data to build both a data chart and a HTML form, which displays the name and color of each line on the chart &#8212; and which handles a redrawing after selecting and deselecting individual items on the form.  </p>
<h3>Abstract some of the heavy lifting</h3>
<p>Yahoo&#8217;s own examples are pretty cool, but drawing a chart isn&#8217;t exactly a one-line job. I wanted to make it &#8212; so I&#8217;ll be able to do something like this:</p>
<pre><code class="javascript">var rent = {displayName:'Rent', data:rentValues};
var utilities = {displayName:'Utillities',
  data:utillitiesValues};

prepareChart('container',
  [rent, utillities], 'formatFunction');</code></pre>
<p>&#8230;where <tt>container</tt> is the name of the html elements holding the chart and the legend, and where <tt>formatFunction</tt> is a reference to the JavaScript function responsible for formating data on the Y-axis.</p>
<p>The data objects can be expanded slightly to include both information about the color of the line and when the dataset should be shown by default:</p>
<pre><code class="javascript">var rent = {displayName:'Rent', data:rentValues,
  hidden:true, color:'#cc0022'};</code></pre>
<h3>In action&#8230;</h3>
<p><a href="/examples/yuichart-with-selectable-legend">&raquo; See it in action</a></p>
<p>The example generates some <a href="/examples/yuichart-with-selectable-legend/random-data.js">random data</a> about a fictive web site and displays &#8220;New signups&#8221;, &#8220;Total number of users&#8221;, &#8220;Active users&#8221; and &#8220;Returning users&#8221; for the past two months (if somebody has ideas for real data to plot, please let me know). This it simply does:</p>
<pre><code class="javascript">var signupsPerDay = {displayName:'New signups',
  data:randomSignupUsers};
var numusersPerDay = {displayName:'Total number of users',
  data:randomTotalUsers, hidden:true};
var activeusersPerDay = {displayName:'Active users',
  data:randomActiveUsers};
var returningusersPerDay = {displayName:'Returning users',
  data:randomReturningUsers};

prepareChart('users',
  [signupsPerDay, numusersPerDay,
    activeusersPerDay, returningusersPerDay],
  'usersCountFormat');</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.refresh.dk/chart-with-selectable-legend-yui-demo/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Library for easy sparklining</title>
		<link>http://www.refresh.dk/easy-sparklines-link/</link>
		<comments>http://www.refresh.dk/easy-sparklines-link/#comments</comments>
		<pubDate>Wed, 12 Dec 2007 13:26:36 +0000</pubDate>
		<dc:creator>Steffen Tiedemann Christensen</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.refresh.dk/easy-sparklines-link/</guid>
		<description><![CDATA[I&#8217;m actually not planning on writing much about charts and graphs &#8212; but since we&#8217;re prototyping the back-end of Nosco&#8217;s prediction market application I&#8217;ve been reading a lot about the subject. For big and interactive charts we&#8217;ll be using either YUI Charts or some native Flex stuff depending on the level of ambitiousness, but John [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m actually not planning on writing much about charts and graphs &#8212; but since we&#8217;re prototyping the back-end of Nosco&#8217;s prediction market application I&#8217;ve been reading a lot about the subject. For big and interactive charts we&#8217;ll be using either <a href="http://www.refresh.dk/charting-with-yui/">YUI Charts</a> or some native Flex stuff depending on the level of ambitiousness, but <a href="http://ejohn.org/projects/jspark/">John Resig&#8217;s JavaScript Sparklines</a> demonstrates how to do something a little simpler in a much, much simpler fashion.</p>
<p>Basically, you insert an html element containing the data for the <a href="http://en.wikipedia.org/wiki/Sparkline">sparkline</a> &#8212; and then the library does the rest for you by creating a <tt>&lt;canvas&gt;</tt> element and drawing the sparkline:</p>
<pre><code class="html">&lt;span class="sparkline"&gt;10,8,20,5...&lt;/span&gt;</code></pre>
<p>Very, very cool&#8230; Although the library doesn&#8217;t seem to support baselines and highlighting of the min and max values, which takes some of the coolness out of the idea of sparklines.</p>
<p>Remember to use <a href="http://excanvas.sourceforce.net/">excanvas</a> as well to emulate canvas support in Internet Explorer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.refresh.dk/easy-sparklines-link/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Charting is a nightmare&#8230;</title>
		<link>http://www.refresh.dk/charting-is-a-nightmare/</link>
		<comments>http://www.refresh.dk/charting-is-a-nightmare/#comments</comments>
		<pubDate>Sat, 08 Dec 2007 09:52:17 +0000</pubDate>
		<dc:creator>Steffen Tiedemann Christensen</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[HTML hacks]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.refresh.dk/charting-is-a-nightmare/</guid>
		<description><![CDATA[It&#8217;s nice to see Google entering the scene for easy chart building &#8212; along with Yahoo&#8217;s Chart library and new JavaScript/Canvas-based stuff like Ole Laursen&#8217;s Flot. Frankly, I&#8217;ve been postponing doing a pretty chart based reporting tool for Nosco&#8217;s prediction markets for quite a while now (we do build nice charts for the web app [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s nice to see <a href="http://code.google.com/apis/chart/">Google entering the scene</a> for easy chart building &#8212; along with <a href="http://www.refresh.dk/charting-with-yui/">Yahoo&#8217;s Chart library</a> and new JavaScript/Canvas-based stuff like <a href="http://ole-laursen.blogspot.com/2007/12/flot-01-released.html">Ole Laursen&#8217;s Flot</a>. Frankly, I&#8217;ve been postponing doing a pretty chart based reporting tool for <a href="http://www.nosco.dk/?p=162">Nosco&#8217;s prediction markets</a> for quite a while now (we do build nice charts for the web app though) but all of this could be becoming easier.</p>
<p>I&#8217;m still not jumping deliriously up and down. My first experiments with YUI Charts were mixed, and for everything it lets you do there&#8217;s two or three things out of reach. The same thing probably goes for Google&#8217;s hosted solution and it&#8217;s worth approaching the service with <a href="http://gulopine.gamemusic.org/2007/12/google-chart-api-revisited.html">a bit of skepticism</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.refresh.dk/charting-is-a-nightmare/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Charting with YUI</title>
		<link>http://www.refresh.dk/charting-with-yui/</link>
		<comments>http://www.refresh.dk/charting-with-yui/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 10:36:28 +0000</pubDate>
		<dc:creator>Steffen Tiedemann Christensen</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Charting]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://praxis.refresh.dk/charting-with-yui/</guid>
		<description><![CDATA[Yahoo&#8217;s web programming framework, YUI, is out in a new version, which frankly wouldn&#8217;t be too exciting if it wasn&#8217;t for the new Charts library. Basically, quite a few people have been experimenting with doing charts and graphs with on html canvases (including myself). This method can work well for specific purposes, but it certainly [...]]]></description>
			<content:encoded><![CDATA[<p>Yahoo&#8217;s web programming framework, <a href="http://developer.yahoo.com/yui/">YUI</a>, is out in <a href="http://yuiblog.com/blog/2007/12/04/yuii-240/">a new version</a>, which frankly wouldn&#8217;t be too exciting if it wasn&#8217;t for the new <a href="http://developer.yahoo.com/yui/charts/">Charts library</a>. Basically, quite a few people have been experimenting with doing charts and graphs with on html canvases (including <a href="http://nyhedsspillet.politiken.dk/market/contract?contract_id=32570">myself</a>). This method can work well for specific purposes, but it certainly doesn&#8217;t scale well, and nobody has come up with a good general library for all charting needs yet.</p>
<p>And the YUI team hasn&#8217;t either. Instead, they&#8217;ve taken a much more interesting approach by building a JavaScript library for accessing Flash&#8217;s (or Flex&#8217;s?) Charting engine. Hopefully (in time) we&#8217;ll get all the power of Flex Charting through YUI.</p>
<p><span class="Apple-style-span" style="font-weight: bold">Update:</span> Apparently, this is a joint project between the Flash and JavaScript teams at Yahoo, so <a href="http://www.yswfblog.com/blog/">the Flashy people</a> have <a href="http://www.yswfblog.com/blog/2007/12/04/yui-got-a-little-more-flashy-today/">more info on the YUI utility</a>.</p>
<p><strong>Updated update:</strong> It also turns out that this isn&#8217;t based on Flex Charting, rather it&#8217;s built on top of a Yahoo-specific Flash library. This probably makes it less interesting?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.refresh.dk/charting-with-yui/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
