Share RGraph:
Share RGraph on Twitter Share RGraph on Google Plus Share RGraph on Facebook Follow RGraph on LinkedIn

Annotating your charts

[No canvas support]

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

How do annotations work?

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

myGraph.set('annotatable', true);

Browser support

Annotations are supported in all browsers that RGraph works with - Firefox 3.5+, Chrome 2+, Safari 4+, Opera 10.5+ and MSIE/Google Chrome Frame. They DO NOT however work with MSIE 7/8+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?

Depending on what browser you'e using - yes. If you're using a modern browser (ie Firefox 3.5+, Chrome 6+, IE9+ etc) then you probably won't have any problems. The annotation data is stored in the users browser (not on the web server) and the user does not have to confirm anything for storage to be allowed - try it out on this page by drawing on the chart 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('contextmenu', [
                          ['Show palette', RGraph.showpalette],
                          ['Clear', function () {RGraph.clear(myObj.canvas); myObj.draw();}]
                         ]);

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

How can I clear the annotations?

You can use the API function, and then clear the canvas and redraw it.
<script>
    RGraph.clearAnnotations((myGraph.canvas); // Clear the annotation data
    RGraph.clear(myGraph.canvas);             // Clear the chart
    RGraph.redrawCanvas(bar.canvas);          // Redraw it
</script>

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

Replaying annotations when they're off

When annotations are not enabled, any prior annotations that may have been made are not displayed. To show them you need to use the API function RGraph.ReplayAnnotations(object) after the call to .draw().

© Copyright 2014 Richard Heyes All rights reserved.