source: Dev/branches/rest-dojo-ui/jQueryUI/client/RGraph/docs/bar.html @ 312

Last change on this file since 312 was 312, checked in by jkraaijeveld, 13 years ago
File size: 37.4 KB
Line 
1<?php ob_start('ob_gzshandler') ?>
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 - bar charts documentation</title>
22   
23    <meta name="keywords" content="rgraph html5 canvas docs bar charts" />
24    <meta name="description" content="RGraph: Javascript charts and graph library - Documentation about the Bar 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.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
34    <script>
35      var _gaq = _gaq || [];
36      _gaq.push(['_setAccount', 'UA-54706-2']);
37      _gaq.push(['_trackPageview']);
38   
39      (function() {
40        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
41        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
42        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
43      })();
44    </script>
45</head>
46<body>
47
48   
49    <!-- Social networking buttons -->
50        <div id="social_icons" class="warning" style="border-radius: 10px; top: 1px; position: fixed">
51            <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>
52            <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>
53        </div>
54
55        <script>
56            // Opera fix
57            if (navigator.userAgent.indexOf('Opera') == -1) {
58              document.getElementById("social_icons").style.position = 'fixed';
59            }
60        </script>
61    <!-- Social networking buttons -->
62
63    <div id="breadcrumb">
64        <a href="../index.html">RGraph: Javascript charts and graph library</a>
65        >
66        <a href="index.html">Documentation</a>
67        >
68        Bar charts
69    </div>
70 
71    <h1>RGraph: <span>Javascript charts and graph library</span> - Bar charts documentation</h1>
72
73    <script>
74        if (RGraph.isIE8()) {
75            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>');
76        }
77    </script>
78 
79    <p>
80        Bar charts, along with Line charts, are the most configurable of all the charts available,
81        because they're the most common of chart types.
82    </p>
83   
84    <p>
85        The example file is <a href="../examples/bar.html">here</a>.
86    </p>
87
88    <ul>
89        <li><a href="#available.properties">Properties</a></li>
90        <li><a href="#available.methods">Methods</a></li>
91    </ul>
92
93    <pre class="code">
94&lt;script&gt;
95    window.onload = function ()
96    {
97        var data = [280,45,133,166,84,259,266,960,219,311];
98   
99        var bar = new RGraph.Bar('myCanvas', data);
100        bar.Set('chart.labels', ['Richard', 'Alex', 'Nick', 'Scott', 'Kjnell', 'Doug', 'Charles', 'Michelle', 'Mark', 'Alison']);
101        bar.Set('chart.gutter.left', 45);
102        bar.Set('chart.background.barcolor1', 'rgba(255,255,255,1)');
103        bar.Set('chart.background.barcolor2', 'rgba(255,255,255,1)');
104        bar.Set('chart.background.grid', true);
105        bar.Set('chart.colors', ['rgba(255,0,0,1)']);
106        bar.Draw();
107    }
108&lt;/script&gt;
109</pre>
110
111    <a name="available.properties"></a>
112    <h2>Properties</h2>
113 
114    <p>
115        You can use these properties to control how the bar chart apears. You can set them by using the Set() method. Eg:
116    </p>
117   
118    <p>
119        <b>myBar.Set('name', 'value');</b>
120    </p>
121   
122    <ul>
123        <li><a href="#background">Background</a></li>
124        <li><a href="#axes">Axes properties</a></li>
125        <li><a href="#colors">Colors</a></li>
126        <li><a href="#margins">Margins</a></li>
127        <li><a href="#labels and text">Labels and text</a></li>
128        <li><a href="#titles">Titles</a></li>
129        <li><a href="#shadow">Shadow</a></li>
130        <li><a href="#scale">Scale</a></li>
131        <li><a href="#key">Key</a></li>
132        <li><a href="#interactive features">Interactive features</a></li>
133        <li><a href="#zoom">Zoom</a></li>
134        <li><a href="#miscellaneous">Miscellaneous</a></li>
135    </ul>
136
137
138<a name="background"></a>
139<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">Background</h3>            <a name="chart.background.barcolor1"></a>
140<b>chart.background.barcolor1</b><br />
141            The color of the background bars, (1 of 2). <br /><i>Default: white</i><br /><br />
142            <a name="chart.background.barcolor2"></a>
143<b>chart.background.barcolor2</b><br />
144            The color of the background bars, (2 of 2). <br /><i>Default: white</i><br /><br />
145            <a name="chart.background.grid"></a>
146<b>chart.background.grid</b><br />
147            Whether to show the background grid or not. <br /><i>Default: true</i><br /><br />
148            <a name="chart.background.grid.color"></a>
149<b>chart.background.grid.color</b><br />
150            The color of the background grid. <br /><i>Default: #ddd</i><br /><br />
151            <a name="chart.background.grid.hsize"></a>
152<b>chart.background.grid.hsize</b><br />
153            The horizontal background grid size. <br /><i>Default: 40</i><br /><br />
154            <a name="chart.background.grid.vsize"></a>
155<b>chart.background.grid.vsize</b><br />
156            The vertical background grid size. <br /><i>Default: 18</i><br /><br />
157            <a name="chart.background.grid.width"></a>
158<b>chart.background.grid.width</b><br />
159            The width that the background grid lines are. Decimals (eg 0.5) are permitted.<br /><i>Default: 1</i><br /><br />
160            <a name="chart.background.grid.border"></a>
161<b>chart.background.grid.border</b><br />
162            Determines whether a border line is drawn around the grid.<br /><i>Default: true</i><br /><br />
163            <a name="chart.background.grid.hlines"></a>
164<b>chart.background.grid.hlines</b><br />
165            Determines whether to draw the horizontal grid lines.<br /><i>Default: true</i><br /><br />
166            <a name="chart.background.grid.vlines"></a>
167<b>chart.background.grid.vlines</b><br />
168            Determines whether to draw the vertical grid lines.<br /><i>Default: true</i><br /><br />
169            <a name="chart.background.grid.autofit"></a>
170<b>chart.background.grid.autofit</b><br />
171            Instead of specifying a pixel width/height for the background grid, you can use autofit and specify how many horizontal and vertical lines you want.<br /><i>Default: false</i><br /><br />
172            <a name="chart.background.grid.autofit.numhlines"></a>
173<b>chart.background.grid.autofit.numhlines</b><br />
174            When using autofit this allows you to specify how many horizontal grid lines you want. <br /><i>Default: 7</i><br /><br />
175            <a name="chart.background.grid.autofit.numvlines"></a>
176<b>chart.background.grid.autofit.numvlines</b><br />
177            When using autofit this allows you to specify how many vertical grid lines you want. <br /><i>Default: 20</i><br /><br />
178           
179            <a name="chart.background.grid.autofit.align"></a>
180            <b>chart.background.grid.autofit.align</b><br />
181            If you want to have your grid lines line up with the labels (both X and Y axes), you can set this to true and RGraph will
182            attempt to make the grid lines line up. If you have a <i>chart.hmargin</i> set then the alignment will be thrown out.<br />
183            <i>Default: false</i><br /><br />
184           
185            <a name="chart.background.hbars"></a>
186<b>chart.background.hbars</b><br />
187            An array of information stipulating horizontal coloured bars. You can use these to indicate limits. Eg: <i>myBar.Set('hbars', [[75, 10, 'yellow'], [85, 15, 'red']]);</i> This would give you two bars, one red and a lower yellow bar. The units correspond to your scale, and are the starting point and the height.<br /><i>Default: null</i><br /><br />
188           
189            <a name="chart.background.image"></a>
190            <b>chart.background.image</b><br />
191            If you want to specify a background image to use on your chart, specify it with this property.<br />
192            <i>Default: null</i><br /><br />
193
194<a name="axes"></a>
195<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">Axes properties</h3>
196
197            <a name="chart.noaxes"></a>
198            <b>chart.noaxes</b><br />
199            Whether the axes are drawn<br />
200            <i>Default: false (the axes ARE drawn)</i><br /><br />
201
202            <a name="chart.noxaxis"></a>
203            <b>chart.noxaxis</b><br />
204            Whether the X axis is drawn<br />
205            <i>Default: false (the X axis IS drawn)</i><br /><br />
206
207            <a name="chart.noyaxis"></a>
208            <b>chart.noyaxis</b><br />
209            Whether the Y axis is drawn<br />
210            <i>Default: false (the Y axis IS drawn)</i><br /><br />
211
212            <a name="chart.noendxtick"></a>
213            <b>chart.noendxtick</b><br />
214            When you're combining the Bar and Line charts, you may want to use this property to stop the end X tick from
215            being drawn.<br />
216            <i>Default: false (the end tick IS drawn)</i><br /><br />
217
218<a name="colors"></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">Colors</h3>            <a name="chart.strokecolor"></a>
220<b>chart.strokecolor</b><br />
221            The color of the outline of the bars. <br /><i>Default: #666</i><br /><br />
222           
223            <a name="chart.colors"></a>
224            <b>chart.colors</b><br />
225            An array of the colors of the actual bars. <br />
226            <i>Default: An array - ['rgb(0,0,255)', '#0f0', '#00f', '#ff0', '#0ff', '#0f0']</i><br /><br />
227           
228            <a name="chart.colors.sequential"></a>
229            <b>chart.colors.sequential</b><br />
230            If true, for regular bar charts, (not stacked or grouped), the colors that you specify will be used in a sequential
231            fashion.<br />
232            <i>Default: false</i><br /><br />
233           
234            <a name="chart.colors.reverse"></a>
235            <b>chart.colors.reverse</b><br />
236            If true, for stacked bar charts only, the colors that you specify will be used in a reverse order to what they are
237            normally.<br />
238            <i>Default: false</i><br /><br />
239
240<a name="margins"></a>
241<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>
242
243        <a name="chart.hmargin"></a>
244        <b>chart.hmargin</b><br />
245            The horizontal margin (in pixels) of the chart. The horizontal margin is on the inside of the axes.<br />
246            <i>Default: 5</i><br /><br />
247
248            <a name="chart.gutter.left"></a>
249            <b>chart.gutter.left</b><br />
250            The left gutter of the chart, (the gutter is where the labels and title are)).<br />
251            <i>Default: 25</i><br /><br />
252
253            <a name="chart.gutter.right"></a>
254            <b>chart.gutter.right</b><br />
255            The right gutter of the chart, (the gutter is where the labels and title are).<br />
256            <i>Default: 25</i><br /><br />
257
258            <a name="chart.gutter.top"></a>
259            <b>chart.gutter.top</b><br />
260            The top gutter of the chart, (the gutter is where the labels and title are).<br />
261            <i>Default: 25</i><br /><br />
262
263            <a name="chart.gutter.bottom"></a>
264            <b>chart.gutter.bottom</b><br />
265            The bottom gutter of the chart, (the gutter is where the labels and title are).<br />
266            <i>Default: 25</i><br /><br />
267
268<a name="labels and text"></a>
269<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.color"></a>
270<b>chart.text.color</b><br />
271            The color of the labels. <br /><i>Default: black</i><br /><br />
272            <a name="chart.text.size"></a>
273<b>chart.text.size</b><br />
274            The size (in points) of the labels. <br /><i>Default: 10</i><br /><br />
275            <a name="chart.text.angle"></a>
276<b>chart.text.angle</b><br />
277            The angle of the horizontal text labels (at the bottom of the chart). This can be one of three values - 0, 45 or 90.<br /><i>Default: 0 (Horizontal)</i><br /><br />
278            <a name="chart.text.font"></a>
279<b>chart.text.font</b><br />
280            The font used to render the text.<br /><i>Default: Verdana</i><br /><br />
281            <a name="chart.labels"></a>
282<b>chart.labels</b><br />
283            An array of the labels to be used on the chart. <br /><i>Default: An empty array</i><br /><br />
284           
285            <a name="chart.labels.above"></a>
286            <b>chart.labels.above</b><br />
287            If true, values will be shown above the bars. For regular and stacked bar charts units are included, whereas for
288            grouped bar charts they're not (usually there isn't enough space for them).
289            <br /><i>Default: false</i><br /><br />
290           
291            <a name="chart.labels.above.decimals"></a>
292            <b>chart.labels.above.decimals</b><br />
293            This stipulates how many decimals are used in the above bar labels.
294            <br /><i>Default: 0</i><br /><br />
295           
296            <a name="chart.labels.above.size"></a>
297            <b>chart.labels.above.size</b><br />
298            The font size of the above bar labels. Useful if you only have a few bars.
299            <br /><i>Default: false</i><br /><br />
300           
301            <a name="chart.labels.above.angle"></a>
302            <b>chart.labels.above.angle</b><br />
303            You can use this to angle the text shown above the bars. It can be anything from -90 to 90 (degrees).
304            <br /><i>Default: null</i><br /><br />
305           
306            <a name="chart.labels.ingraph"></a>
307<b>chart.labels.ingraph</b><br />
308            An array of labels for the chart which are drawn "inside" the chart.  If you have 5 data points then this should have a corresponding number of elements, though there is a <a href="misc.html#shorthand.ingraph.labels">shorthand available</a>.<br /><i>Default: null</i><br /><br />
309           
310            <a name="chart.ylabels"></a>
311            <b>chart.ylabels</b><br />
312            Can be <i>true</i> or <i>false</i> and determines whether the chart has Y axis labels.<br />
313            <i>Default: true</i><br /><br />
314
315            <a name="chart.ylabels.count"></a>
316            <b>chart.ylabels.count</b><br />
317            A value  that controls how many Y labels there are. Previously (prior to 8th August 2010) this could be 1,3,5.
318            Now it can be any number, but keep in mind that if you use this it may result in decimals.<br />
319            <i>Default: 5</i><br /><br />
320
321            <a name="chart.ylabels.specific"></a>
322            <b>chart.ylabels.specific</b><br />
323            You can use this option to give your own Y labels (eg ['Low', 'Medium', 'High'].<br />
324            <i>Default: null</i><br /><br />
325
326            <a name="chart.xlabels.offset"></a>
327<b>chart.xlabels.offset</b><br />
328            This allows you finer grained control over the X label positioning if you need it.<br /><i>Default: 0</i><br /><br />
329            <a name="chart.numyticks"></a>
330<b>chart.numyticks</b><br />
331            The number of Y tickmarks. If you have changed the number of Y labels, you may also want to change this to match. <br /><i>Default: 10</i><br /><br />
332<a name="titles"></a>
333
334<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>
335
336<a name="chart.title"></a>
337<b>chart.title</b><br />
338The title of the chart, if any. <br />
339<i>Default: null</i><br /><br />
340
341<a name="chart.title.background"></a>
342<b>chart.title.background</b><br />
343The background color (if any) for the title.<br />
344<i>Default: null</i><br /><br />
345
346<a name="chart.title.color"></a>
347<b>chart.title.color</b><br />
348            The color of the title.<br /> <i>Default: black</i><br /><br />
349            <a name="chart.title.hpos"></a>
350<b>chart.title.hpos</b><br />
351            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 />
352            <a name="chart.title.vpos"></a>
353<b>chart.title.vpos</b><br />
354            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 />
355            <a name="chart.title.xaxis"></a>
356<b>chart.title.xaxis</b><br />
357            This allows to specify a title for the X axis.<br /><i>Default: none</i><br /><br />
358            <a name="chart.title.yaxis"></a>
359<b>chart.title.yaxis</b><br />
360            This allows to specify a title for the Y axis.<br /><i>Default: none</i><br /><br />
361            <a name="chart.title.xaxis.pos"></a>
362<b>chart.title.xaxis.pos</b><br />
363            This is multiplied with the gutter to give the position of the X axis title.<br /><i>Default: 0.25</i><br /><br />
364            <a name="chart.title.yaxis.pos"></a>
365<b>chart.title.yaxis.pos</b><br />
366            This is multiplied with the gutter to give the position of the Y axis title.<br /><i>Default: 0.25</i><br /><br />
367
368<!--
369            <a name="chart.title.yaxis.position"></a>
370            <b>chart.title.yaxis.align</b><br />
371            Instead of using the option above you can instead use this option, specifying <i>left</i> or <i>right</i>.<br />
372            <i>Default: left</i><br /><br />
373-->
374
375<a name="shadow"></a>
376<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">Shadow</h3>            <a name="chart.shadow"></a>
377<b>chart.shadow</b><br />
378            Whether a drop shadow is applied. <br /><i>Default: false</i><br /><br />
379            <a name="chart.shadow.color"></a>
380<b>chart.shadow.color</b><br />
381            The color of the shadow. <br /><i>Default: #666</i><br /><br />
382            <a name="chart.shadow.offsetx"></a>
383<b>chart.shadow.offsetx</b><br />
384            The X offset of the shadow. <br /><i>Default: 3</i><br /><br />
385            <a name="chart.shadow.offsety"></a>
386<b>chart.shadow.offsety</b><br />
387            The Y offset of the shadow.  <br /><i>Default: 3</i><br /><br />
388            <a name="chart.shadow.blur"></a>
389<b>chart.shadow.blur</b><br />
390            The severity of the shadow blurring effect. <br /><i>Default: 3</i><br /><br />
391
392            <a name="scale"></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">Scale</h3>
394           
395            <a name="chart.scale.formatter"></a>
396            <b>chart.scale.formatter</b><br />
397            To allow thoroughly custom formats of numbers in the scale, you can use this option to
398            specify a function that is used by RGraph to format numbers. This function should
399            handle ALL of the formatting. Eg:<br /><br />
400            <pre class="code">
401function myFormatter(obj, num)
402{
403    return num + 'F'; // An example of formatting
404}
405myGraph.Set('chart.scale.formatter', myFormatter);
406</pre>
407            <br /><i>Default: null</i><br /><br />
408           
409            <a name="chart.scale.decimals"></a>
410            <b>chart.scale.decimals</b><br />
411            The number of decimal places to display for the Y scale.
412            <br /><i>Default: 0</i><br /><br />
413           
414            <a name="chart.scale.point"></a>
415            <b>chart.scale.point</b><br />
416            The character used as the decimal point.<br /><i>Default: .</i><br /><br />
417           
418            <a name="chart.scale.round"></a>
419            <b>chart.scale.round</b><br />
420            Whether to round the maximum scale value up or not. This will produce slightly better scales in some instances.<br />
421            <i>Default: null</i><br /><br />
422
423            <a name="chart.units.pre"></a>
424            <b>chart.units.pre</b><br />
425            The units that the Y axis is measured in. This string is displayed BEFORE the actual number, allowing you to specify values such as "$50".<br /><i>Default: none</i><br /><br />
426           
427            <a name="chart.units.post"></a>
428            <b>chart.units.post</b><br />
429            The units that the Y axis is measured in. This string is displayed AFTER the actual number, allowing you to specify values such as "50ms".<br /><i>Default: none</i><br /><br />
430
431            <a name="chart.ymax"></a>
432            <b>chart.ymax</b><br />
433            The optional maximum Y scale value. If not specified then it will be calculated.<br /><i>Default: null (It's calculated)</i><br /><br />
434
435
436            <a name="key"></a>
437            <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>
438           
439            <a name="chart.key"></a>
440            <b>chart.key</b><br />
441            An array of key information. <br />
442            <i>Default: [] (An empty array)</i><br /><br />
443
444            <a name="chart.key.background"></a>
445            <b>chart.key.background</b><br />
446            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>
447            <i>Default: white</i><br /><br />
448           
449            <a name="chart.key.halign"></a>
450            <b>chart.key.halign</b><br />
451            Instead of specifying the exact x/y coordinates, you can use this property to simply specify whether the key hould be
452            aligned <i>left</i> or <i>right</i>.<br />
453            <i>Default: right</i><br /><br />
454           
455            <a name="chart.key.position"></a>
456            <b>chart.key.position</b><br />
457            Determines the position of the key.Either <b>graph</b> (default), or <b>gutter</b>.<br />
458            <i>Default: graph</i><br /><br />
459           
460            <b>chart.key.position.x</b><br />
461            This allows you to specify a specific X coordinate for the key.<br />
462            <i>Default: null</i><br /><br />
463           
464            <b>chart.key.position.y</b><br />
465            This allows you to specify a specific Y coordinate for the key.<br />
466            <i>Default: null</i><br /><br />
467           
468            <b>chart.key.position.gutter.boxed</b><br />
469            If you have the key in gutter mode (ie horizontal), this allows you to give a background color.<br />
470            <i>Default: true</i><br /><br />
471           
472            <a name="chart.key.shadow"></a>
473            <b>chart.key.shadow</b><br />
474            Whether a small drop shadow is applied to the key.<br />
475            <i>Default: false</i><br /><br />
476
477            <a name="chart.key.shadow.color"></a>
478            <b>chart.key.shadow.color</b><br />
479            The color of the shadow.<br />
480            <i>Default: #666</i><br /><br />
481
482            <a name="chart.key.shadow.blur"></a>
483            <b>chart.key.shadow.blur</b><br />
484            The extent of the blurring effect used on the shadow.<br />
485            <i>Default: 3</i><br /><br />
486
487            <a name="chart.key.shadow.offsetx"></a>
488            <b>chart.key.shadow.offsetx</b><br />
489            The X offset of the shadow.<br />
490            <i>Default: 2</i><br /><br />
491
492            <a name="chart.key.shadow.offsety"></a>
493            <b>chart.key.shadow.offsety</b><br />
494            The Y offset of the shadow.<br />
495            <i>Default: 2</i><br /><br />
496
497            <b>chart.key.rounded</b><br />
498            This controls whether the corners of the key (in graph mode) are curved. If the key is gutter mode, this has no effect.<br />
499            <i>Default: false</i><br /><br />
500           
501            <b>chart.key.color.shape</b><br />
502            This can be <i>square</i>, <i>circle</i> or <i>line</i> and controls how the color indicators in the key appear.<br />
503            <i>Default: square</i><br /><br />
504           
505            <b>chart.key.linewidth</b><br />
506            The line width of the surrounding border on the key.<br />
507            <i>Default: 1</i><br /><br />
508
509
510
511<a name="interactive features"></a>
512<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>            <a name="chart.contextmenu"></a>
513<b>chart.contextmenu</b><br />
514            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 />
515            <a name="chart.tooltips"></a>
516<b>chart.tooltips</b><br />
517            A numerically indexed array of tooltips that are shown when a bar is clicked. These can contain HTML.<br /><i>Default: null</i><br /><br />
518            <a name="chart.tooltips.effect"></a>
519<b>chart.tooltips.effect</b><br />
520            The animated effect used for showing tooltips. Can be either <i>fade</i> or <i>expand</i>.<br /><i>Default: fade</i><br /><br />
521           
522            <a name="chart.tooltips.event"></a>
523            <b>chart.tooltips.event</b><br />
524            This is the event that triggers the tooltips. It can be either <i>onclick</i> or <i>onmousemove</i>.<br />
525            <i>Default: onclick</i><br /><br />
526
527            <a name="chart.tooltips.css.class"></a>
528<b>chart.tooltips.css.class</b><br />
529            This is the name of the CSS class the chart uses.<br /><i>Default: RGraph_tooltip</i><br /><br />
530            <a name="chart.tooltips.override"></a>
531<b>chart.tooltips.override</b><br />
532            If you wish to handle showing tooltips yourself, this should be a function object which does just that. There's more information on the <a href="tooltips.html">tooltips documentation page</a><br /><i>Default: null</i><br /><br />
533           
534           
535            <a name="chart.crosshairs"></a>
536<b>chart.crosshairs</b><br />
537            If true, you will get a crosshair centering on the current mouse position.<br /><i>Default: false</i><br /><br />
538            <a name="chart.crosshairs.linewidth"></a>
539<b>chart.crosshairs.linewidth</b><br />
540            This controls the linewidth of the crosshairs.<br /><i>Default: 1</i><br /><br />
541            <a name="chart.crosshairs.color"></a>
542<b>chart.crosshairs.color</b><br />
543            The color of the crosshairs.<br /><i>Default: #333</i><br /><br />
544            <a name="chart.annotatable"></a>
545<b>chart.annotatable</b><br />
546            Whether annotations are enabled for the chart (ie you can draw on the chart interactively.<br /><i>Default: false</i><br /><br />
547            <a name="chart.annotate.color"></a>
548<b>chart.annotate.color</b><br />
549            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 />
550           
551            <a name="chart.resizable"></a>
552            <b>chart.resizable</b><br />
553            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 />
554            <i>Default: false</i><br /><br />
555
556            <a name="chart.resize.handle.background"></a>
557            <b>chart.resize.handle.background</b><br />
558            With this you can specify the background color for the resize handle. If you're adjusting the position of the
559            handle then you may need this to make the handle stand out more.<br />
560            <i>Default: null</i><br /><br />
561
562            <a name="chart.adjustable"></a>
563<b>chart.adjustable</b><br />
564            Defaulting to false, this determines whether your bar chart will be adjustable. <br /><i>Default: false</i><br /><br />
565
566<a name="zoom"></a>
567<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>
568<a name="chart.zoom.mode"></a>
569<b>chart.zoom.mode</b><br />
570            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 />
571            <a name="chart.zoom.factor"></a>
572<b>chart.zoom.factor</b><br />
573            This is the factor that the chart will be zoomed by (bigger values means more zoom)<br /><i>Default: 1.5</i><br /><br />
574            <a name="chart.zoom.fade.in"></a>
575<b>chart.zoom.fade.in</b><br />
576            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 />
577            <a name="chart.zoom.fade.out"></a>
578<b>chart.zoom.fade.out</b><br />
579            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 />
580            <a name="chart.zoom.hdir"></a>
581<b>chart.zoom.hdir</b><br />
582            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 />
583            <a name="chart.zoom.vdir"></a>
584<b>chart.zoom.vdir</b><br />
585            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 />
586            <a name="chart.zoom.delay"></a>
587<b>chart.zoom.delay</b><br />
588            The delay (in milliseconds) between frames.<br /><i>Default: 50</i><br /><br />
589            <a name="chart.zoom.frames"></a>
590<b>chart.zoom.frames</b><br />
591            The number of frames in the zoom animation.<br /><i>Default: 10</i><br /><br />
592            <a name="chart.zoom.shadow"></a>
593<b>chart.zoom.shadow</b><br />
594            Whether or not the zoomed canvas has a shadow or not.<br /><i>Default: true</i><br /><br />
595            <a name="chart.zoom.thumbnail.width"></a>
596<b>chart.zoom.thumbnail.width</b><br />
597            When the zoom is in thumbnail mode, this is the width (in pixels) of the thumbnail.<br /><i>Default: 75</i><br /><br />
598            <a name="chart.zoom.thumbnail.height"></a>
599<b>chart.zoom.thumbnail.height</b><br />
600            When the zoom is in thumbnail mode, this is the height (in pixels) of the thumbnail.<br /><i>Default: 75</i><br /><br />
601            <a name="chart.zoom.background"></a>
602<b>chart.zoom.background</b><br />
603            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 />
604
605
606    <a name="miscellaneous"></a>
607    <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>
608        <a name="chart.highlight.stroke"></a>
609        <b>chart.highlight.stroke</b><br />
610        If you use tooltips, this controls the colour of the highlight stroke.
611        <br /><i>Default: black</i><br /><br />
612
613        <a name="chart.highlight.fill"></a>
614        <b>chart.highlight.fill</b><br />
615        If you use tooltips, this controls the colour of the highlight fill.
616        <br /><i>Default: rgba(255,255,255,0.5)</i><br /><br />
617
618<a name="chart.line"></a>
619<b>chart.line</b><br />
620            Formerly a boolean, this now stipulates a line chart object which is to be drawn on top of the bar chart. You can see an example <a href="combine.html">here</a>.<br /><i>Default: null</i><br /><br />
621            <a name="chart.variant"></a>
622<b>chart.variant</b><br />
623            This simply stipulates whether you want a regular bar chart, a dot chart, a pyramid chart a 3D chart, a sketch or a glassy chart. Possible values are:<ul><li>bar</li><li>dot</li><li>pyramid</li><li>arrow</li><li>3d</li><li>sketch</li><li>glass</li></ul>The pyramid, dot, arrow, sketch and glass variants are only effective for regular bar charts - not grouped or stacked charts.<br /><i>Default: bar</i><br /><br />
624           
625            <a name="chart.xaxispos"></a>
626            <b>chart.xaxispos</b><br />
627            The position of the X axis. This can be <i>bottom</i>,  <i>center</i> or <i>top</i>. <br />
628            <i>Default: bottom</i><br /><br />
629
630            <a name="chart.axis.color"></a>
631<b>chart.axis.color</b><br />
632            The color of the axes.<br /><i>Default: black</i><br /><br />
633            <a name="chart.grouping"></a>
634<b>chart.grouping</b><br />
635            How the bars are grouped, and it should be one of: <b>grouped</b> or <b>stacked</b><br /><i>Default: grouped</i><br /><br />
636</div>
637   
638    <a name="available.methods"></a>
639    <br />&nbsp;<br />
640    <h2>Methods</h2>
641   
642    <a name="getbar"></a>
643    <b>obj.getBar()</b><br /><br />
644    This method makes it easier to get hold of which bar has been clicked on, or hovered over. It returns an array of:
645    <ul>
646        <li>The chart object</li>
647        <li>The X coordinate</li>
648        <li>The Y coordinate</li>
649        <li>The width of the bar</li>
650        <li>The height of the bar</li>
651        <li>The numerical index of the bar. This corresponds (for example) to the tooltips array, and the coordinates array</li>
652    </ul>
653   
654    An example usage is:
655   
656    <pre class="code">
657&lt;canvas id="cvs" width="600" height="250"&gt;[No canvas support]&lt;/canvas&gt;
658
659&lt;script src="RGraph.common.core.js"&gt;&lt;/script&gt;
660&lt;script src="RGraph.bar.js"&gt;&lt;/script&gt;
661
662&lt;script&gt;
663    myGraph = new RGraph.Bar('myCanvas', [1.2, 1.3, 1.4, 1.5,6,1.9,2,2.1,2.5]);
664    myGraph.Set('chart.labels', ['John', 'Barry', 'Rich', 'Craig', 'Tom', 'Frank', 'Helen', 'Joyce', 'Fred'])
665    myGraph.Draw();
666
667    RGraph.Register(myGraph);
668   
669    myGraph.canvas.onclick = function (e)
670    {
671        RGraph.Redraw();
672   
673        var canvas  = e.target;
674        var context = canvas.getContext('2d');
675        var obj     = canvas.__object__;
676        <span style="color: green">var coords  = obj.getBar(e);</span>
677       
678        if (coords) {
679            var top    = coords[1];
680            var left   = coords[2];
681            var width  = coords[3];
682            var height = coords[4];
683           
684            context.beginPath();
685                context.strokeStyle = 'black';
686                context.fillStyle = 'rgba(255,255,255,0.5)';
687                context.strokeRect(top, left, width, height);
688                context.fillRect(top, left, width, height);
689            context.stroke();
690            context.fill();
691        }
692    }
693&lt;/script&gt;
694</pre>
695   
696   
697</body>
698</html>
Note: See TracBrowser for help on using the repository browser.