Recently I've been working on a time tracking application for my wife so that she can track time and generate invoices for her fledgling consulting business.
*Shameless plug: If you need any UI design help, she's awesome, really. Her designs are sharp and professional, and she'll even build it out in HTML for you. You can contact me at jfiorato at gmail dot com if you're interested in her services.*
One of the things I wanted to add to this application, is some charts that display some interesting metrics. I'd had some mild exposure to YUI's charts, and found the flash rendering of charts preferable to the image generation that you get with Google's recently released chart API.
To connect ADO.NET Data Services with the Yahoo Chart API, I'm going to do the following:
- Create my simple ADO.NET Data Service.
- Add a reference to the ADO.NET Data Services client side library.
- Add references to the Yahoo UI Chart API.
- Pipe the results to a Yahoo DataSource
- Provide the DataSource to the Yahoo Chart API
So, first thing I'm going to do is create my data service. This involves creating a Linq to Sql class and making it available as a service. You can follow the most of the instructions from my post about creating a simple REST service with ASP.NET Data Services.
Next I'll add my references to the ADO.NET Data Services Client Side UI Library to the ScriptManager:
Now, the only bummer about this is that I have to use the ADO.NET Data Services Client Libraries. The Yahoo Datasource is perfectly capable of taking a URL that returns either XML or JSON and populating itself. However, it appears that the JSON that ADO.NET Data Services generates isn't exactly valid JSON, according to www.json.org and the Yahoo JSON parser.
I guess there isn't a whole lot of code here anyway. So it's not too bad. Another limitation, is that when you're building charts you usually need to do some grouping and sorting of those groups to get interesting chart data. From what limited documentation there is on this right now, I can't find a way to do any grouping of the data through the URL Addressing Scheme.