Experimenting with Protovis

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.

[pvis src=”http://stubbornmule.net/scripts/pv/test.js” img=”http://stubbornmule.net/blog/wp-content/CDO-circles.png” height=”125px”]CDO deals: total and recycled[/pvis]

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):

13 thoughts on “Experimenting with Protovis

  1. Pingback: Getting Protovis working on Wordpress

  2. Jesse

    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. Danny Yee

    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

  4. Pingback: Protovis now working in Chrome and Safari

  5. Richard Volpato

    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.

  6. Stubborn Mule Post author

    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 Reply