[77] | 1 | <?php ob_start('ob_gzhandler') ?> |
---|
| 2 | <!DOCTYPE html > |
---|
| 3 | <html> |
---|
| 4 | <head> |
---|
| 5 | <meta http-equiv="X-UA-Compatible" content="chrome=1"> |
---|
| 6 | <!-- |
---|
| 7 | /** |
---|
| 8 | * o------------------------------------------------------------------------------o |
---|
| 9 | * | This file is part of the RGraph package - you can learn more at: | |
---|
| 10 | * | | |
---|
| 11 | * | http://www.rgraph.net | |
---|
| 12 | * | | |
---|
| 13 | * | This package is licensed under the RGraph license. For all kinds of business | |
---|
| 14 | * | purposes there is a small one-time licensing fee to pay and for non | |
---|
| 15 | * | commercial purposes it is free to use. You can read the full license here: | |
---|
| 16 | * | | |
---|
| 17 | * | http://www.rgraph.net/LICENSE.txt | |
---|
| 18 | * o------------------------------------------------------------------------------o |
---|
| 19 | */ |
---|
| 20 | --> |
---|
| 21 | <title>RGraph: Javascript charts and graph library - Annotating your charts</title> |
---|
| 22 | |
---|
| 23 | <meta name="keywords" content="rgraph html5 canvas chart docs annotating" /> |
---|
| 24 | <meta name="description" content="RGraph: Javascript charts and graph library - Documentation about annotating your charts" /> |
---|
| 25 | |
---|
| 26 | <meta property="og:title" content="RGraph: Javascript charts and graph library" /> |
---|
| 27 | <meta property="og:description" content="A chart library based on the HTML5 canvas tag" /> |
---|
| 28 | <meta property="og:image" content="http://www.rgraph.net/images/logo.png"/> |
---|
| 29 | |
---|
| 30 | <link rel="stylesheet" href="../css/website.css" type="text/css" media="screen" /> |
---|
| 31 | <link rel="icon" type="image/png" href="../images/favicon.png"> |
---|
| 32 | |
---|
| 33 | <script src="../libraries/RGraph.common.core.js" ></script> |
---|
| 34 | <script src="../libraries/RGraph.common.annotate.js" ></script> |
---|
| 35 | <script src="../libraries/RGraph.common.context.js" ></script> |
---|
| 36 | <script src="../libraries/RGraph.common.zoom.js" ></script> |
---|
| 37 | <script src="../libraries/RGraph.bar.js" ></script> |
---|
| 38 | <!--[if IE 8]><script src="../excanvas/excanvas.original.js"></script><![endif]--> |
---|
| 39 | |
---|
| 40 | <script> |
---|
| 41 | window.onload = function () |
---|
| 42 | { |
---|
| 43 | bar = new RGraph.Bar('myBar', [[45,64],[32,51],[41,52],[54,43],[43,50]]); |
---|
| 44 | bar.Set('chart.title', 'An annotatable chart with context menu'); |
---|
| 45 | bar.Set('chart.labels', ['John','Fred', 'Barry', 'Charlie', 'Joan']); |
---|
| 46 | bar.Set('chart.colors', ['red', 'blue']); |
---|
| 47 | bar.Set('chart.background.barcolor1', '#fff'); |
---|
| 48 | bar.Set('chart.background.barcolor2', '#fff'); |
---|
| 49 | bar.Set('chart.annotatable', true); |
---|
| 50 | bar.Set('chart.contextmenu', [['Show palette', RGraph.Showpalette], ['Clear', function () {RGraph.Clear(bar.canvas); bar.Draw();}]]); |
---|
| 51 | bar.Draw(); |
---|
| 52 | |
---|
| 53 | RGraph.AddCustomEventListener(bar, 'onannotatestart', function (obj) {cl('Started annotating: ' + obj.id);}); |
---|
| 54 | RGraph.AddCustomEventListener(bar, 'onannotate', function (obj) {cl('Annotating: ' + obj.id);}); |
---|
| 55 | RGraph.AddCustomEventListener(bar, 'onannotateend', function (obj) {cl('Finished annotating: ' + obj.id);}); |
---|
| 56 | RGraph.AddCustomEventListener(bar, 'onannotatecolor', function (obj) {cl('Changed annotate color: ' + obj.Get('chart.annotate.color'));}); |
---|
| 57 | RGraph.AddCustomEventListener(bar, 'onannotateclear', function (obj) {cl('Fired the annotation clear event');}); |
---|
| 58 | } |
---|
| 59 | </script> |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | <script> |
---|
| 63 | var _gaq = _gaq || []; |
---|
| 64 | _gaq.push(['_setAccount', 'UA-54706-2']); |
---|
| 65 | _gaq.push(['_trackPageview']); |
---|
| 66 | |
---|
| 67 | (function() { |
---|
| 68 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
---|
| 69 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
---|
| 70 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
---|
| 71 | })(); |
---|
| 72 | </script> |
---|
| 73 | </head> |
---|
| 74 | <body> |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | <!-- Social networking buttons --> |
---|
| 78 | <div id="social_icons" class="warning" style="border-radius: 10px; top: 1px; position: fixed"> |
---|
| 79 | <a title="Bookmark with delicious" href="http://delicious.com/save?jump=close&v=4&noui&jump=close&url=http://www.rgraph.net¬es=RGraph%20is%20a%20HTML5%20based%20javascript%20charts%20library%20supporting%20a%20wide%20range%20of%20different%20charts%20types&title=RGraph:Javascript%20charts%20and%20graphs%20library" target="_blank"><img src="../images/delicious.png" alt="Bookmark with delicious" width="22" height="22" border="0" align="absmiddle" /></a> |
---|
| 80 | <a href="http://twitter.com/home/?status=RGraph%3A%20Javascript+charts+and+graph+library+http%3A%2F%2Fwww.rgraph.net+%23rgraph+%23html5+%23canvas+%23javascript+%23charts+@_rgraph" target="_blank"><img src="../images/twitter.png" id="twitter_icon" alt="tweet this site" width="22" height="22" border="0" align="absmiddle" /></a> |
---|
| 81 | </div> |
---|
| 82 | |
---|
| 83 | <script> |
---|
| 84 | // Opera fix |
---|
| 85 | if (navigator.userAgent.indexOf('Opera') == -1) { |
---|
| 86 | document.getElementById("social_icons").style.position = 'fixed'; |
---|
| 87 | } |
---|
| 88 | </script> |
---|
| 89 | <!-- Social networking buttons --> |
---|
| 90 | |
---|
| 91 | <div id="breadcrumb"> |
---|
| 92 | <a href="../index.html">RGraph: Javascript charts and graph library</a> |
---|
| 93 | > |
---|
| 94 | <a href="index.html">Documentation</a> |
---|
| 95 | > |
---|
| 96 | Annotating your charts |
---|
| 97 | </div> |
---|
| 98 | |
---|
| 99 | <h1>RGraph: <span>Javascript charts and graph library</span> - Annotating your charts</h1> |
---|
| 100 | |
---|
| 101 | <script> |
---|
| 102 | if (RGraph.isIE8()) { |
---|
| 103 | document.write('<div style="background-color: #fee; border: 2px dashed red; padding: 5px"><b>Important</b><br /><br /> Internet Explorer 8 does not natively support the HTML5 canvas tag, so if you want to see the charts, you can either:<ul><li>Install <a href="http://code.google.com/chrome/chromeframe/">Google Chrome Frame</a></li><li>Use ExCanvas. This is provided in the RGraph Archive.</li><li>Use another browser entirely. Your choices are Firefox 3.5+, Chrome 2+, Safari 4+ or Opera 10.5+. </li></ul> <b>Note:</b> Internet Explorer 9 fully supports the canvas tag. Click <a href="http://support.rgraph.net/message/rgraph-in-internet-explorer-9.html" target="_blank">here</a> to see some screenshots.</div>'); |
---|
| 104 | } |
---|
| 105 | </script> |
---|
| 106 | |
---|
| 107 | <div style="float: right"> |
---|
| 108 | <canvas id="myBar" width="400" height="200">[No canvas support]</canvas><br /> |
---|
| 109 | </div> |
---|
| 110 | |
---|
| 111 | <p> |
---|
| 112 | The annotations feature brings presentation style functionality to RGraph charts. You can use this feature |
---|
| 113 | for highlighting your charts if you need to. |
---|
| 114 | </p> |
---|
| 115 | |
---|
| 116 | <ul> |
---|
| 117 | <li><a href="#how">How do annotations work?</a></li> |
---|
| 118 | <li><a href="#browser">Browser support</a></li> |
---|
| 119 | <li><a href="#what">What can I use annotations for?</a></li> |
---|
| 120 | <li><a href="#persistent">Are annotations persistent?</a></li> |
---|
| 121 | <li><a href="#palette">How do I show the mini-palette?</a></li> |
---|
| 122 | <li><a href="#clear">How can I clear the annotations?</a></li> |
---|
| 123 | <li><a href="#replay">Replaying annotations when they're off</a></li> |
---|
| 124 | <li><a href="#persist">Making your annotations persist</a></li> |
---|
| 125 | </ul> |
---|
| 126 | |
---|
| 127 | <a name="how"></a> |
---|
| 128 | <h4>How do annotations work?</h4> |
---|
| 129 | |
---|
| 130 | <p> |
---|
| 131 | Enabling annotations is a very simple affair, and consists of doing the following: |
---|
| 132 | </p> |
---|
| 133 | |
---|
| 134 | <pre class="code" style="width: 55%">myGraph.Set('chart.annotatable', true);</pre> |
---|
| 135 | |
---|
| 136 | <a name="browser"></a> |
---|
| 137 | <h4>Browser support</h4> |
---|
| 138 | |
---|
| 139 | <p> |
---|
| 140 | Annotations are supported in all browsers that RGraph works with - Firefox 3.5+, Chrome 2+, Safari 4+, Opera 10.5+ and |
---|
| 141 | MSIE/Google Chrome Frame. They DO NOT however work with MSIE 8/ExCanvas. |
---|
| 142 | </p> |
---|
| 143 | |
---|
| 144 | <a name="what"></a> |
---|
| 145 | <h4>What can I use annotations for?</h4> |
---|
| 146 | |
---|
| 147 | <p> |
---|
| 148 | As mentioned you can use it for presentations, highlighting things to yourself or others or just to have fun drawing (!). |
---|
| 149 | </p> |
---|
| 150 | |
---|
| 151 | <a name="persistent"></a> |
---|
| 152 | <h4>Are annotations persistent?</h4> |
---|
| 153 | |
---|
| 154 | <p> |
---|
| 155 | That depends on which browser you're using. The annotation data is stored in the users web browser (not on the web server), |
---|
| 156 | meaning currently (21st March 2010) browser support is limited to Firefox 3.5+, Safari 4+, |
---|
| 157 | Chrome 4+ and Opera 10.5+. MSIE 8 also has the required storage capabilities, but since it doesn't yet support canvas, the point is moot. |
---|
| 158 | The user does not have to |
---|
| 159 | confirm anything for storage to be allowed - try it out on this page by drawing on the chart and then refreshing the page. |
---|
| 160 | </p> |
---|
| 161 | |
---|
| 162 | <a name="palette"></a> |
---|
| 163 | <h4>How do I show the mini-palette?</h4> |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | <p> |
---|
| 167 | You can show the palette by using the <i>RGraph.Showpalette</i> function shown below as a context menu item: |
---|
| 168 | </p> |
---|
| 169 | |
---|
| 170 | <pre class="code"> |
---|
| 171 | myObj.Set('chart.contextmenu', [ |
---|
| 172 | ['Show palette', RGraph.Showpalette], |
---|
| 173 | ['Clear', function () {RGraph.Clear(myObj.canvas); myObj.Draw();}] |
---|
| 174 | ]); |
---|
| 175 | </pre> |
---|
| 176 | |
---|
| 177 | <p> |
---|
| 178 | This code will result in the same context menu as the chart above. |
---|
| 179 | </p> |
---|
| 180 | |
---|
| 181 | <a name="clear"></a> |
---|
| 182 | <h4>How can I clear the annotations?</h4> |
---|
| 183 | |
---|
| 184 | You can simply clear the chart and redraw it: |
---|
| 185 | |
---|
| 186 | <pre class="code">RGraph.Clear(myGraph.canvas); // Clear the chart |
---|
| 187 | myGraph.Draw(); // Redraw it</pre> |
---|
| 188 | |
---|
| 189 | <p> |
---|
| 190 | In the chart above, there is a context menu that allows you to both clear the chart and also demonstrates the mini-palette |
---|
| 191 | feature available to you. |
---|
| 192 | </p> |
---|
| 193 | |
---|
| 194 | <a name="replay"></a> |
---|
| 195 | <h4>Replaying annotations when they're off</h4> |
---|
| 196 | <p> |
---|
| 197 | When annotations are not enabled, any prior annotations that may have been made are not displayed. To show them you need |
---|
| 198 | to use the API function <i>RGraph.ReplayAnnotations(object)</i> after the call to .Draw(). |
---|
| 199 | </p> |
---|
| 200 | |
---|
| 201 | <a name="persist"></a> |
---|
| 202 | <h4>Making your annotations persist across browsers/computers</h4> |
---|
| 203 | <p> |
---|
| 204 | With a little bit of custom Javascript and some server side scripting you can make your annotations persist across |
---|
| 205 | different browsers/computers. You can find an example of this <a href="annotate_persist.html"><b>here</b></a>. |
---|
| 206 | </p> |
---|
| 207 | |
---|
| 208 | </html> |
---|