source: Dev/branches/rest-dojo-ui/Demo/RGraph/docs/pie.html @ 312

Last change on this file since 312 was 312, checked in by jkraaijeveld, 13 years ago
File size: 25.6 KB
Line 
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 - Pie charts documentation</title>
22   
23    <meta name="keywords" content="rgraph html5 canvas chart docs pie charts" />
24    <meta name="description" content="RGraph: Javascript charts and graph library - Documentation about the Pie charts" />
25   
26    <meta property="og:title" content="RGraph: Javascript charts and graph library" />
27    <meta property="og:description" content="A charts library based on the HTML5 canvas tag" />
28    <meta property="og:image" content="http://www.rgraph.net/images/logo.jpg"/>
29
30    <link rel="stylesheet" href="../css/website.css" type="text/css" media="screen" />
31    <link rel="icon" type="image/png" href="/favicon.png">
32
33    <script>
34      var _gaq = _gaq || [];
35      _gaq.push(['_setAccount', 'UA-54706-2']);
36      _gaq.push(['_trackPageview']);
37   
38      (function() {
39        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
40        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
41        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
42      })();
43    </script>
44
45</head>
46<body>
47
48    <!-- Social networking buttons -->
49        <div id="social_icons" class="warning" style="border-radius: 10px; top: 1px; position: fixed">
50            <a title="Bookmark with delicious" href="http://delicious.com/save?jump=close&v=4&noui&jump=close&url=http://www.rgraph.net&notes=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>
51            <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>
52        </div>
53
54        <script>
55            // Opera fix
56            if (navigator.userAgent.indexOf('Opera') == -1) {
57              document.getElementById("social_icons").style.position = 'fixed';
58            }
59        </script>
60    <!-- Social networking buttons -->
61
62    <div id="breadcrumb">
63        <a href="../index.html">RGraph: Javascript charts and graph library</a>
64        >
65        <a href="index.html">Documentation</a>
66        >
67        Pie charts
68    </div>
69
70    <h1>RGraph: <span>Javascript charts and graph library</span> - Pie charts documentation</h1>
71
72    <script>
73        if (RGraph.isIE8()) {
74            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>');
75        }
76    </script>
77
78    <p>
79        The pie chart can be used, for example, to represent something that is akin to percentages. ie A set of data that
80        should be taken as part of a whole.
81    </p>
82   
83    <p>
84        The example file is <a href="../examples/pie.html">here</a>.
85    </p>
86   
87    <pre class="code">
88&lt;script&gt;
89    window.onload = function ()
90    {
91        var data = [564,155,499,611,322];
92   
93        var pie = new RGraph.Pie('myPie', data);
94        pie.Set('chart.labels', ['Abc', 'Def', 'Ghi', 'Jkl', 'Mno']);
95        pie.Set('chart.linewidth', 5);
96        pie.Set('chart.stroke', '#fff');
97        pie.Draw();
98    }
99&lt;/script&gt;
100</pre>
101   
102    <a name="available.properties"></a>
103    <ul>
104        <li><a href="#available.properties">Properties</a></li>
105        <li><a href="#available.methods">Methods</a></li>
106    </ul>
107
108    <h2>Properties</h2>
109
110    <p>
111        You can use these properties to control how the pie chart looks. You can set them by using the Set() method. Eg:
112    </p>
113   
114    <p>
115        <b>myPie.Set('name', 'value');</b>
116    </p>
117   
118    <ul>
119        <li><a href="#margins">Margins</a></li>
120        <li><a href="#colors">Colors</a></li>
121        <li><a href="#labels and text">Labels and text</a></li>
122        <li><a href="#titles">Titles</a></li>
123        <li><a href="#shadows">Shadows</a></li>
124        <li><a href="#interactive features">Interactive features</a></li>
125        <li><a href="#key">Key</a></li>
126        <li><a href="#zoom">Zoom</a></li>
127        <li><a href="#scale">Scale</a></li>
128        <li><a href="#miscellaneous">Miscellaneous</a></li>
129    </ul>
130
131
132<a name="margins"></a>
133<h3 style="border: 1px solid #aaa; background-color: #eee; font-style: italic; padding: 5px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px">Margins</h3>
134
135
136
137            <a name="chart.gutter.left"></a>
138            <b>chart.gutter.left</b><br />
139            The left gutter of the chart, (the gutter is where the labels and title are)).<br />
140            <i>Default: 25</i><br /><br />
141
142            <a name="chart.gutter.right"></a>
143            <b>chart.gutter.right</b><br />
144            The right gutter of the chart, (the gutter is where the labels and title are).<br />
145            <i>Default: 25</i><br /><br />
146
147            <a name="chart.gutter.top"></a>
148            <b>chart.gutter.top</b><br />
149            The top gutter of the chart, (the gutter is where the labels and title are).<br />
150            <i>Default: 25</i><br /><br />
151
152            <a name="chart.gutter.bottom"></a>
153            <b>chart.gutter.bottom</b><br />
154            The bottom gutter of the chart, (the gutter is where the labels and title are).<br />
155            <i>Default: 25</i><br /><br />
156
157<a name="colors"></a>
158<h3 style="border: 1px solid #aaa; background-color: #eee; font-style: italic; padding: 5px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px">Colors</h3>            <a name="chart.colors"></a>
159<b>chart.colors</b><br />
160            Colors to be used for the pie segments. <br /><i>Default: ['rgb(255,0,0)', '#ddd', 'rgb(0,255,0)', 'rgb(0,0,255)', 'rgb(255,255,0)', 'rgb(0,255,255)', 'red', 'pink', 'black', 'white']</i><br /><br />
161            <a name="chart.strokestyle"></a>
162<b>chart.strokestyle</b><br />
163            The color of the seperating lines. By setting this to your background color, and setting the linewidth to approx. 5, it will make the pie chart look "exploded". <br /><i>Default: #999</i><br /><br />
164<a name="labels and text"></a>
165<h3 style="border: 1px solid #aaa; background-color: #eee; font-style: italic; padding: 5px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px">Labels and text</h3>            <a name="chart.text.size"></a>
166<b>chart.text.size</b><br />
167            The size of the text (in points). <br /><i>Default: 10</i><br /><br />
168            <a name="chart.text.font"></a>
169<b>chart.text.font</b><br />
170            The font used to render the text.<br /><i>Default: Verdana</i><br /><br />
171            <a name="chart.text.color"></a>
172<b>chart.text.color</b><br />
173            The color of the labels. <br /><i>Default: black</i><br /><br />
174            <a name="chart.labels"></a>
175<b>chart.labels</b><br />
176            An array of labels to be used for the chart. <br /><i>Default: [] (an empty array)</i><br /><br />
177            <a name="chart.labels.sticks"></a>
178<b>chart.labels.sticks</b><br />
179            Stipulates that small sticks for the labels are shown. The <a href="../examples/pie.html">example page</a> has an example of this.<br /><i>Default: false</i><br /><br />
180            <a name="chart.labels.sticks.color"></a>
181<b>chart.labels.sticks.color</b><br />
182            Sets the color of the label sticks.<br /><i>Default: #aaa</i><br /><br />
183<a name="titles"></a>
184<h3 style="border: 1px solid #aaa; background-color: #eee; font-style: italic; padding: 5px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px">Titles</h3>            <a name="chart.title"></a>
185<b>chart.title</b><br />
186            The title of the pie chart. <br /><i>Default: none</i><br /><br />
187
188<a name="chart.title.background"></a>
189<b>chart.title.background</b><br />
190The background color (if any) for the title.<br />
191<i>Default: null</i><br /><br />
192
193            <a name="chart.title.color"></a>
194<b>chart.title.color</b><br />
195            The color of the title.<br /> <i>Default: black</i><br /><br />
196            <a name="chart.title.hpos"></a>
197<b>chart.title.hpos</b><br />
198            This allows you to completely override the horizontal positioning of the title. It should be a number between 0 and 1, and is multiplied with the whole width of the canvas and then used as the horizontal position. <br /><i>Default: null</i><br /><br />
199            <a name="chart.title.vpos"></a>
200<b>chart.title.vpos</b><br />
201            This allows you to completely override the vertical positioning of the title. It should be a number between 0 and 1, and is multiplied with the gutter and then used as the vertical position. It can be useful if you need to have a large gutter.<br /><i>Default: null</i><br /><br />
202<a name="shadows"></a>
203<h3 style="border: 1px solid #aaa; background-color: #eee; font-style: italic; padding: 5px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px">Shadows</h3>            <a name="chart.shadow"></a>
204<b>chart.shadow</b><br />
205            Whether a simple shadow effect is applied. <br /><i>Default: false</i><br /><br />
206            <a name="chart.shadow.color"></a>
207<b>chart.shadow.color</b><br />
208            The color of the shadow. <br /> <i>Default: rgba(0,0,0,0.5)</i><br /><br />
209            <a name="chart.shadow.blur"></a>
210<b>chart.shadow.blur</b><br />
211            The severity of the shadow blurring effect. <br /> <i>Default: 3</i><br /><br />
212            <a name="chart.shadow.offsetx"></a>
213<b>chart.shadow.offsetx</b><br />
214            The X offset of the shadow.<br /><i>Default: 3</i><br /><br />
215            <a name="chart.shadow.offsety"></a>
216<b>chart.shadow.offsety</b><br />
217            The Y offset of the shadow.<br /><i>Default: 3</i><br /><br />
218<a name="interactive features"></a>
219<h3 style="border: 1px solid #aaa; background-color: #eee; font-style: italic; padding: 5px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px">Interactive features</h3>
220
221            <a name="chart.tooltips"></a>
222            <b>chart.tooltips</b><br />
223            An array of tooltips, starting from the middle right (ie east) axis, and going clockwise sequentially.<br />
224            <i>Default: [] (An empty array)</i><br /><br />
225
226            <a name="chart.tooltips.event"></a>
227            <b>chart.tooltips.event</b><br />
228            This can be <i>onclick</i> or <i>onmousemove</i> and determines which event is used for tooltips.<br />
229            <i>Default: onclick</i><br /><br />
230
231            <a name="chart.tooltips.effect"></a>
232            <b>chart.tooltips.effect</b><br />
233            The animated effect used for showing tooltips. Can be either <i>fade</i> or <i>expand</i>.<br />
234            <i>Default: fade</i><br /><br />
235           
236            <a name="chart.tooltips.css.class"></a>
237            <b>chart.tooltips.css.class</b><br />
238            This is the name of the CSS class the chart uses.<br />
239            <i>Default: RGraph_tooltip</i><br /><br />
240           
241            <a name="chart.tooltips.override"></a>
242            <b>chart.tooltips.override</b><br />
243            If you wish to handle showing tooltips yourself, this should be a function object which does just that. There's more
244            information on the <a href="tooltips.html">tooltips documentation page</a><br />
245            <i>Default: null</i><br /><br />
246
247
248            <a name="chart.contextmenu"></a>
249<b>chart.contextmenu</b><br />
250            An array of context menu items. More information on context menus is <a href="context.html">here</a>.<br /><i>Default: [] (An empty array)</i><br /><br />
251            <a name="chart.annotatable"></a>
252<b>chart.annotatable</b><br />
253            Whether annotations are enabled for the chart (ie you can draw on the chart interactively.<br /><i>Default: false</i><br /><br />
254            <a name="chart.annotate.color"></a>
255<b>chart.annotate.color</b><br />
256            If you do not allow the use of the palette, then this will be the only colour allowed for annotations.<br /><i>Default: black</i><br /><br />
257
258
259
260            <a name="chart.resizable"></a>
261            <b>chart.resizable</b><br />
262            Defaulting to false, this determines whether your chart will be resizable. Because of the numerous event handlers this has to install code on, This feature is unlikely to work with other dynamic features (the context menu is fine however).<br />
263            <i>Default: false</i><br /><br />
264
265
266            <a name="chart.resize.handle.background"></a>
267            <b>chart.resize.handle.background</b><br />
268            With this you can specify the background color for the resize handle. If you're adjusting the position of the
269            handle then you may need this to make the handle stand out more.<br />
270            <i>Default: null</i><br /><br />
271
272
273
274
275
276            <a name="key"></a>
277            <h3 style="border: 1px solid #aaa; background-color: #eee; font-style: italic; padding: 5px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px">Key</h3>
278           
279            <a name="chart.key"></a>
280            <b>chart.key</b><br />
281            An array of key information. <br />
282            <i>Default: [] (An empty array)</i><br /><br />
283
284            <a name="chart.key.background"></a>
285            <b>chart.key.background</b><br />
286            The color of the key background. Typically white, you could set this to something like rgba(255,255,255,0.7) to allow people to see things behind it.<br>
287            <i>Default: white</i><br /><br />
288           
289            <a name="chart.key.halign"></a>
290            <b>chart.key.halign</b><br />
291            Instead of specifying the exact x/y coordinates, you can use this property to simply specify whether the key hould be
292            aligned <i>left</i> or <i>right</i>.<br />
293            <i>Default: right</i><br /><br />
294           
295            <a name="chart.key.position"></a>
296            <b>chart.key.position</b><br />
297            Determines the position of the key.Either <b>graph</b> (default), or <b>gutter</b>.<br />
298            <i>Default: graph</i><br /><br />
299           
300            <b>chart.key.position.x</b><br />
301            This allows you to specify a specific X coordinate for the key.<br />
302            <i>Default: null</i><br /><br />
303           
304            <b>chart.key.position.y</b><br />
305            This allows you to specify a specific Y coordinate for the key.<br />
306            <i>Default: null</i><br /><br />
307           
308            <b>chart.key.position.gutter.boxed</b><br />
309            If you have the key in gutter mode (ie horizontal), this allows you to give a background color.<br />
310            <i>Default: true</i><br /><br />
311           
312            <a name="chart.key.shadow"></a>
313            <b>chart.key.shadow</b><br />
314            Whether a small drop shadow is applied to the key.<br />
315            <i>Default: false</i><br /><br />
316
317            <a name="chart.key.shadow.color"></a>
318            <b>chart.key.shadow.color</b><br />
319            The color of the shadow.<br />
320            <i>Default: #666</i><br /><br />
321
322            <a name="chart.key.shadow.blur"></a>
323            <b>chart.key.shadow.blur</b><br />
324            The extent of the blurring effect used on the shadow.<br />
325            <i>Default: 3</i><br /><br />
326
327            <a name="chart.key.shadow.offsetx"></a>
328            <b>chart.key.shadow.offsetx</b><br />
329            The X offset of the shadow.<br />
330            <i>Default: 2</i><br /><br />
331
332            <a name="chart.key.shadow.offsety"></a>
333            <b>chart.key.shadow.offsety</b><br />
334            The Y offset of the shadow.<br />
335            <i>Default: 2</i><br /><br />
336
337            <b>chart.key.rounded</b><br />
338            This controls whether the corners of the key (in graph mode) are curved. If the key is gutter mode, this has no effect.<br />
339            <i>Default: false</i><br /><br />
340           
341            <b>chart.key.color.shape</b><br />
342            This can be <i>square</i>, <i>circle</i> or <i>line</i> and controls how the color indicators in the key appear.<br />
343            <i>Default: square</i><br /><br />
344           
345            <b>chart.key.linewidth</b><br />
346            The line width of the surrounding border on the key.<br />
347            <i>Default: 1</i><br /><br />
348
349
350
351<a name="zoom"></a>
352<h3 style="border: 1px solid #aaa; background-color: #eee; font-style: italic; padding: 5px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px">Zoom</h3>            <a name="chart.zoom.mode"></a>
353<b>chart.zoom.mode</b><br />
354            Can be used to control whether the zoom is in thumbnail or canvas mode. Possible values are: <i>thumbnail</i> and <i>canvas</i>.<br /><i>Default: canvas</i><br /><br />
355            <a name="chart.zoom.factor"></a>
356<b>chart.zoom.factor</b><br />
357            This is the factor that the chart will be zoomed by (bigger values means more zoom)<br /><i>Default: 1.5</i><br /><br />
358            <a name="chart.zoom.fade.in"></a>
359<b>chart.zoom.fade.in</b><br />
360            Whether the zoomed canvas fades in or not. This also can be used to control the fade in for the zoom in thumbnail mode.<br /><i>Default: true</i><br /><br />
361            <a name="chart.zoom.fade.out"></a>
362<b>chart.zoom.fade.out</b><br />
363            Whether the zoomed canvas fades out or not. This also can be used to control the fade in for the zoom in thumbnail mode.<br /><i>Default: true</i><br /><br />
364            <a name="chart.zoom.hdir"></a>
365<b>chart.zoom.hdir</b><br />
366            The horizontal direction of the zoom. Possible values are: <i>left</i>, <i>center</i>, <i>right</i><br /><i>Default: right</i><br /><br />
367            <a name="chart.zoom.vdir"></a>
368<b>chart.zoom.vdir</b><br />
369            The vertical direction of the zoom. Possible values are: <i>up</i>, <i>center</i>, <i>down</i><br /><i>Default: down</i><br /><br />
370            <a name="chart.zoom.delay"></a>
371<b>chart.zoom.delay</b><br />
372            The delay (in milliseconds) between frames.<br /><i>Default: 50</i><br /><br />
373            <a name="chart.zoom.frames"></a>
374<b>chart.zoom.frames</b><br />
375            The number of frames in the zoom animation.<br /><i>Default: 10</i><br /><br />
376            <a name="chart.zoom.shadow"></a>
377<b>chart.zoom.shadow</b><br />
378            Whether or not the zoomed canvas has a shadow or not.<br /><i>Default: true</i><br /><br />
379            <a name="chart.zoom.thumbnail.width"></a>
380<b>chart.zoom.thumbnail.width</b><br />
381            When the zoom is in thumbnail mode, this is the width (in pixels) of the thumbnail.<br /><i>Default: 75</i><br /><br />
382            <a name="chart.zoom.thumbnail.height"></a>
383<b>chart.zoom.thumbnail.height</b><br />
384            When the zoom is in thumbnail mode, this is the height (in pixels) of the thumbnail.<br /><i>Default: 75</i><br /><br />
385            <a name="chart.zoom.background"></a>
386<b>chart.zoom.background</b><br />
387            Defaulting to true, this determines whether the zoom has a dark, semi-opaque background that covers the entire web page.<br /><i>Default: true</i><br /><br />
388<a name="scale"></a>
389<h3 style="border: 1px solid #aaa; background-color: #eee; font-style: italic; padding: 5px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px">Scale</h3>
390
391
392<a name="miscellaneous"></a>
393<h3 style="border: 1px solid #aaa; background-color: #eee; font-style: italic; padding: 5px; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px">Miscellaneous</h3>            <a name="chart.align"></a>
394<b>chart.align</b><br />
395            Whether to left, center or right align the pie chart.<br /><i>Default: center</i><br /><br />
396            <a name="chart.linewidth"></a>
397<b>chart.linewidth</b><br />
398            By setting this to roughly 5, and setting the strokestyle to the same colour as your background colour,you will get a segment separation effect.<br /><i>Default: 1</i><br /><br />
399           
400            <a name="chart.variant"></a>
401            <b>chart.variant</b><br />
402            This can be either <i>pie</i> (the default) or <i>donut</i>. Setting this to <i>donut</i> is how you get a
403            donut chart.<br />
404            <i>Default: pie</i><br /><br />
405           
406            <a name="chart.variant.donut.color"></a>
407            <b>chart.variant.donut.color</b><br />
408            This is the color of the center of the Donut chart.<br />
409            <i>Default: white</i><br /><br />
410
411            <a name="chart.value.text"></a>
412            <b>chart.value.text</b><br />
413            Set this to true if you want the value displayed in text beow the center of the pointer.<br /><i>Default: false</i><br /><br />
414           
415            <a name="chart.highlight.style"></a>
416            <b>chart.highlight.style</b><br />
417            Can be either <i>explode</i>, <i>2d</i> or <i>3d</i> and determines which style of segment highlighting is used in
418            conjunction with tooltips.<br />
419            <i>Default: 2d</i><br /><br />
420           
421            <a name="chart.highlight.style.2d.fill"></a>
422            <b>chart.highlight.style.2d.fill</b><br />
423            When 2D highlighting for tooltips is used, this controls the color of the highlighting. The former name for this property was
424            <i>chart.highlight.style.2d.color</i>.<br />
425            <i>Default: rgba(255,255,255,0.5)</i><br /><br />
426           
427            <a name="chart.highlight.style.2d.stroke"></a>
428            <b>chart.highlight.style.2d.stroke</b><br />
429            When 2D highlighting for tooltips is used, this controls the stroke color of the highlighting.<br />
430            <i>Default: rgba(255,255,255,0)</i><br /><br />
431           
432            <a name="chart.explode"></a>
433            <b>chart.explode</b><br />
434            This can either be an array with the same number of elements as segments, or a single number, in which case every
435            segment will be exploded that amount. If it's an array then only those segments will be exploded - eg <i>[0,5,0,0]</i><br />
436            <i>Default: [] (an empty array)</i><br /><br />
437</div>
438
439    <a name="available.methods"></a>
440    <br />&nbsp;<br />
441    <h2>Methods</h2>
442
443    <b>obj.getSegment()</b><br /><br />
444   
445    obj.getSegment() makes it easy to determine which segment of the Pie chart was clicked on. It provides:
446   
447    <ul>
448        <li>Originating X coordinate</li>
449        <li>Originating Y coordinate</li>
450        <li>The radius of the segment</li>
451        <li>The starting angle (in degrees)</li>
452        <li>The ending angle (in degrees)</li>
453        <li>The zero-indexed segment number</li>
454    </ul>
455
456    <pre class="code">
457&lt;script&gt;
458    RGraph.Register(myGraph);
459   
460    myGraph.canvas.onclick = function (e)
461    {
462        RGraph.FixEventObject(e);
463        RGraph.Redraw();
464
465        var canvas  = e.target;
466        var context = canvas.getContext('2d');
467        var obj     = canvas.__object__;
468        <span style="color: green">var segment = obj.getSegment(e);</span>
469       
470        if (segment) {
471            context.fillStyle = 'rgba(255,255,255,0.5)';
472            context.beginPath();
473               
474                // Angles are provided in degrees, so convert them to radians
475                segment[3] /= 57.29;
476                segment[4] /= 57.29;
477           
478                context.moveTo(segment[0], segment[1]);
479                context.arc(segment[0], segment[1], segment[2], segment[3], segment[4], 0);
480            context.stroke();
481            context.fill();
482           
483            e.stopPropagation();
484        }
485    }
486   
487    window.onclick = function (e)
488    {
489        RGraph.Redraw();
490    }
491&lt;/script&gt;
492</pre>
493
494    <b>Important Note</b>
495
496    <p>
497        This method was formerly a common object method, called <i>RGraph.getSegment(e)</i>, but has now (6th March 2011) been
498        moved to be part of the Pie chart object.
499    </p>
500
501</body>
502</html>
Note: See TracBrowser for help on using the repository browser.