Experimenting with Protovis

by Stubborn Mule on 6 September 2010 · 13 comments

A couple of weeks ago I gave a talk on using graphics in R. During the question session, someone asked whether I had tried using Protovis, a javascript data visualisation library being developed at Stanford. It was an easy question to answer: no!

However, a bit of subsequent investigation revealed that Protovis has been developed very much in the spirit of Leland Wilkinson’s book The Grammar of Graphics, which I am currently reading, so I have decided to experiment with it here on the blog.

The charts I generate with R are all static images, while a tool like Protovis allows for user interaction which opens up some interesting possibilities. Compared to R, which I have been using for around 10 years, Protovis presents a double challenge: not only do I have to come to grips with Protovis itself, but I will also have to learn some basic Javascript programming. So, I expect it to be a slow journey.

As a tentative first step, I have reproduced the CDO chart from a recent post ranting about bubble charts. At first glance, it is essentially identical to the chart I produced using R. However, if you hover your mouse over the points on the chart, you should see the figures appear! It is by no means perfect (for example, it would probably look better if single points appeared, rather than every point on the chart and it could do with a legend), but it’s a start and I will persevere.

CDO deals: total and recycled

Producing scripts using a Javascript library does have its drawbacks. For a start, it means the chart will only be visible when scripts can be run, so if you are reading this in an email or an RSS news reader, you will probably not see very much and will have to visit the page on the blog to see it. Even then, some of you may use script-blockers such as NoScript which will also break the chart (mind you, you can trust the Mule, so you could always whitelist this site!). Finally, I believe that some older browsers (such as IE6) will not support Protovis. It would be useful to see how many people can or cannot see the chart, so please let me know using this poll whether you can see the chart.


(polls)

Getting Protovis to work on the blog was a little fiddly, so for anyone interested, I have also written up a quick guide to using Protovis on a WordPress blog.

UPDATE: Reports in so far indicate that the chart is not working in Google Chrome or on mobile devices. More work to do it would seem!

Possibly Related Posts (automatically generated):

{ 11 comments… read them below or add one }

1 Jonathan September 6, 2010 at 1:35 pm

A double no – doesn’t work for me via, doesn’t work in Chrome.

2 Jesse September 6, 2010 at 1:45 pm

I’m using the latest Chrome and cannot see them. The examples on the Protovis site work fine.

I’ve been meaning to experiment with it as well. It would be cool to have some interface between a protovis and R in the back.

3 Stubborn Mule September 6, 2010 at 1:55 pm

Thanks for the feedback…a bit of investigation is now required to troubleshoot it on Chrome.

4 pfh007 September 6, 2010 at 4:24 pm

Works fine in Firefox 3.6.8.

5 Stubborn Mule September 6, 2010 at 4:25 pm

Thanks Paul!

6 Danny Yee September 6, 2010 at 5:11 pm

Chrome is printing the following debug (go to spanner, tools, Javascript console to see the Javascript debugging info):

/scripts/pv/cdodraw.js:58Uncaught SyntaxError: Unexpected token this
/protovis/protovis-r3.2.js:6ReferenceError: cdodraw is not defined

7 Simon Rumble September 6, 2010 at 7:43 pm

Works in Firefox/Linux, doesn’t work in Chrome/Linux.

8 Marco aka Cracticus September 7, 2010 at 10:24 am

Hey Stubborn,

Pretty cool, man.

As others, I used Firefox 3.6.8 with no problem.

9 Stubborn Mule September 7, 2010 at 10:30 am

Thanks Marco. It looks as though it’s fine on any Firefox browser, but problematic elsewhere.

10 Richard Volpato September 13, 2010 at 1:58 pm

Hi.

It was me who asked the question at the user group. Impressive response! I think there are a number of benefits with Protovis that can enhance R within enterprise or dispersed user groups (eg readers of your blog).

First, the ‘interactivity’ is critical: how often do we see a graph to realize some other ‘cut’ of the data is important? Well now users can go through the same experience and make a selection (eg with check boxes or whatever) to see the new ‘cut’. This means that the narrative of data can unfold in different ways.

Second, browsers can take up a lot of data, not just the points needed for the initial graph. Thus some of the ‘interactivity’ is entirely client (browser) based. This is particularly interesting if you wanted readers to comment, not on the blog (at the end) but to the graph ‘cut’ in a particular way.

Third, because of the object orientated nature of the graphical objects, there is the prospect of ‘view source’ enabling other users to pick analytic charts that they find useful in other settings. More analytical precision and less ‘glitz’ (from the Flash driven days!) might propagate. (We live in hope).

Finally, the sheer power of R is simply too hidden to enable users (eg in an enterprise) so ‘run’ it themselves. Browser based deliver of highly specific graphical displays that open up a problem in ways EXCEL could not achieve will draw R to the desktops.

In short, protovis, small javascript library that it is, might just have R pouring into people’s lives via browser….. and then onwards downloading R onto the desktop.

11 Stubborn Mule September 13, 2010 at 2:01 pm

Richard: it’s early days for me, but Protovis looks very promising. I will continue to play with it and can certainly see myself using R to explore the data and Protovis to present what I find. Thanks for the question, I’ve enjoyed what I found!

Leave a Comment

 

{ 2 trackbacks }

Previous post:

Next post: