RGraph: HTML5 canvas graph library - Annotating your graphs

[No canvas support]

The annotations feature brings presentation style functionality to RGraph graphs. You can use this feature for highlighting your graphs if you need to.

How do annotations work?

Enabling annotations is a very simple affair, and consists of doing the following:

myGraph.Set('chart.annotatable', true);

Browser support

Annotations are supported in all browsers that RGraph works with - Firefox 3.5+, Chrome 2+ and Safari 4+. However they only persist in certain browsers - Firefox 3.5+, Safari 4+ and Chrome 4+ (dev). They DO NOT work with MSIE/ExCanvas.

What can I use annotations for?

As mentioned you can use it for presentations, highlighting things to yourself or others or just to have fun drawing (!).

Are annotations persistent?

That depends on which browser you're using. The annotation data is stored in the users web browser (not on the web server), meaning currently (5th December 2009) browser support is limited to Firefox 3.5, Safari 4 and Chrome 4 (dev). MSIE 8 also has the required storage capabilities, but since it doesn't yet support canvas, the point is moot. The user does not have to confirm anything for storage to be allowed - try it out on this page by drawing on the graph and then refreshing the page.

How do I show the mini-palette?

You can show the palette by using the RGraph.Showpalette function shown below as a context menu item:

myObj.Set('chart.contextmenu', [
                                ['Show palette', RGraph.Showpalette],
                                ['Clear', function () {RGraph.Clear(myObj.canvas); myObj.Draw();}]

This code will result in the same context menu as the graph above.

How can I clear the annotations?

You can simply clear the graph and redraw it:
RGraph.Clear(myGraph.canvas); // Clear the graph
myGraph.Draw();               // Redraw it

In the graph above, there is a context menu that allows you to both clear the graph and also demonstrates the mini-palette feature available to you.