I know how to create a barplot, and how to stick it on a webpage; e.g, using hwriteImage in the hwriter package.
What I’d like is for each bar to be a region which highlights on mouseover, and where each bar has a different link when clicked. Similar to this map of the U.S. using the jQuery maphilight plugin, but for a barplot rather than a map. I imagine R could calculate the coordinates of the regions around each bar, generate the HTML AREA tag etc and pass this to maphilight quite easily. Has it been done already? I searched but no luck so far.
Have a look here, which summarises a couple of methods:
rggobiandiplots.rggobilooks pretty promising, though maybe the installation looks a bit involved.iplotsis only good for scatter plots.Some other options (I think these are strongest ones at the moment):
googleVis
The googleVis package interfaces with the google charts API: try
demo(googleVis)and the third & fourth one are bar chart (there could be more). It has the advantage of being pretty simple to get started with, although these are not R graphics:gridSVG
The
gridSVGexports the current grid graphics to an .svg file that can be included into a webpage. Unlike googleVis, it’s R graphics (so you can use grid/ggplot2 which are more familiar). It looks like you may have to know some Javascript to further embellish your plots though (e.g. to animate on mouse over, you usegrid.garnish(...,onmouseover=...)).There’s some example code you can try here (The really awesome ones are here – usually clicking on the “SVG file” link will have the full interactivity/animation.) (This one is a scatterplot where the points highlight when you move your mouse over them).
As I said – have a look at the package pages, demos, examples, etc to see which suits you.