December 12, 2007

This morning I mentioned to Steve that we should provide an example mashup of Google Charts with some data store using DekiScript in Deki Wiki to compliment Corey’s previous blog post. We spoke about it for about 2 minutes this morning. A few minutes ago Steve showed me this:

Google Charts MySQL Mashup in Deki Wiki

Cool. He’s performing SQL queries on a MySQL database, in this case a Deki Wiki database and then feeding this to the Google Charts extension. What you see in the first table (above) is the MySQL query presented in a table. You’ve always been able to do this with Deki Wiki. The second item, the pie chart, that you see is the MySQL mashup with Google Charts. To achieve the mashup Steve used the following DekiScript:

{{ google.piechart(400, 200, mysql.values("SELECT (SELECT COUNT(*) FROM pages WHERE user_id = page_user_id) + (SELECT COUNT(*) FROM old WHERE user_id = old_user) AS 'Total Edits' FROM users WHERE user_name != 'Anonymous' ORDER BY user_name"), mysql.values("SELECT user_name AS 'User Name' FROM users WHERE user_name != 'Anonymous' ORDER BY user_name")) }}

Obviously this looks a little ugly, but what can I say: it’s SQL. You get the general idea. This is precisely why the Google Charts extension is interfaced using DekiScript, as was previously asked by a Gardener on Corey’s last blog post. DekiScript makes constructing these kinds of mashups a lot easier and a lot easier to read.

To make this mashup possible Steve had to make a couple minor changes to the MySQL extension. Previously the MySQL extension would only return a table. Today Steve added the ability for the extension to return a single value or an array of values. It took him a couple minutes to make this change, but now you can create some nice MySQL and Google Charts mashups. He’s checking this in today. Free free to have at it from SVN. If you want to wait for the official release 1.8.3 is due out at the end of December.

One Response to “Google Charts and Graphs Redux With a Mashup”

  1. Steve Bjorg Says:

    Minor change to this unshipped code. Instead of "mysql.values", the new function call is "mysql.list"

Leave a Reply