source: Dev/trunk/RGraph/docs/scatter.html @ 77

Last change on this file since 77 was 77, checked in by fpvanagthoven, 14 years ago

RGraph

File size: 40.9 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 personal,    |
15        * | charity and educational purposes it is free to use. You can read the full    |
16        * | license here:                                                                |
17        * |                      http://www.rgraph.net/LICENSE.txt                       |
18        * o------------------------------------------------------------------------------o
19        */
20    -->
21
22    <title>RGraph: Javascript charts and graph library - scatter charts documentation</title>
23
24    <link rel="stylesheet" href="../css/website.css" type="text/css" media="screen" />
25    <link rel="icon" type="image/png" href="/favicon.png">
26   
27    <meta property="og:title" content="RGraph: Javascript charts and graph library - Scatter charts documentation" />
28    <meta property="og:description" content="A charts library based on the HTML5 canvas tag" />
29    <meta property="og:image" content="http://www.rgraph.net/images/logo.jpg"/>
30
31    <script>
32      var _gaq = _gaq || [];
33      _gaq.push(['_setAccount', 'UA-54706-2']);
34      _gaq.push(['_trackPageview']);
35   
36      (function() {
37        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
38        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
39        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
40      })();
41    </script>
42
43</head>
44<body>
45    <a name="top"></a>
46
47    <!-- Social networking buttons -->
48        <div id="social_icons" class="warning" style="border-radius: 10px; top: 1px; position: fixed">
49            <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>
50            <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>
51        </div>
52
53        <script>
54            // Opera fix
55            if (navigator.userAgent.indexOf('Opera') == -1) {
56              document.getElementById("social_icons").style.position = 'fixed';
57            }
58        </script>
59    <!-- Social networking buttons -->
60
61    <div id="breadcrumb">
62        <a href="../index.html">RGraph: Javascript charts and graph library</a>
63        >
64        <a href="index.html">Documentation</a>
65        >
66        Scatter charts
67    </div>
68
69    <h1>RGraph: <span>Javascript charts and graph library</span> - Scatter charts documentation</h1>
70
71    <script>
72        if (RGraph.isIE8()) {
73            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>');
74        }
75    </script>
76
77    <p>
78        Scatter charts. Used to represent many data points over a period of time. For example, events occurring in a given year.
79    </p>
80   
81    <p>
82        The example file is <a href="../examples/scatter.html">here</a>.
83    </p>
84   
85    <ul>
86        <li><a href="#properties">Properties</a></li>
87        <li><a href="#methods">Methods</a></li>
88        <li><a href="#boxplots">Box plots</a></li>
89        <li><a href="#labelpoints">Specific points for labels on the X axis</a></li>
90        <li><a href="#custom.tickmarks">Custom tickmarks</a></li>
91        <li><a href="#colors">Note about colors and the key</a></li>
92    </ul>
93   
94    <pre class="code">
95&lt;script&gt;
96    window.onload = function ()
97    {
98        var data = [
99                    [67,78,null, 'The winner!'], [67,40,'red'], [58,12], [78,56], [365,90], [360,300], [320,150], [15,45],
100                    [16,43], [84,12], [67,89,'green'], [90,23,'green'], [23,80], [80,66], [55,66], [88,12], [43,45], [61,12],
101                    [15,89], [13,16]
102                   ];
103        var sg = new RGraph.Scatter('myScatter', data);
104        sg.Set('chart.background.barcolor1','rgba(255,255,255,1)');
105        sg.Set('chart.background.barcolor2', 'rgba(255,255,255,1)');
106        sg.Set('chart.grid.color', 'rgba(238,238,238,1)');
107        sg.Set('chart.gutter.left', 30);
108        sg.Set('chart.labels', ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
109        sg.Set('chart.xmax', 365); // Important!
110        sg.Draw();
111    }
112&lt;/script&gt;
113</pre>
114
115    <p>
116        As you can see each mark on the Scatter chart is made by supplying an array of up to 4 elements:
117    </p>
118   
119    <ul>
120        <li>The X value (required)</li>
121        <li>The Y value (required)</li>
122        <li>The color (optional)</li>
123        <li>The tooltip for this mark (optional)</li>
124    </ul>
125   
126    <p>
127        If you wish to specify a tooltip, but not a color (ie use the default color instead), you can pass null instead of a color.
128    </p>
129
130
131    <a name="properties"></a>
132    <h2>Properties</h2>
133   
134    <p>
135        You can use these properties to control how the Scatter apears. You can set them by using the Set() method. Eg:
136    </p>
137   
138    <p>
139        <b>myScatter.Set('chart.xmax', 365);</b>
140    </p>
141   
142    <ul>
143        <li><a href="#background">Background</a></li>
144        <li><a href="#labels and text">Labels and text</a></li>
145        <li><a href="#margins">Margins</a></li>
146        <li><a href="#axis properties">Axis properties</a></li>
147        <li><a href="#titles">Titles</a></li>
148        <li><a href="#scale">Scale</a></li>
149        <li><a href="#interactive features">Interactive features</a></li>
150        <li><a href="#line properties">Line properties</a></li>
151        <li><a href="#key">Key</a></li>
152        <li><a href="#zoom">Zoom</a></li>
153        <li><a href="#miscellaneous">Miscellaneous</a></li>
154    </ul>
155
156
157<a name="background"></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">Background</h3>            <a name="chart.background.barcolor1"></a>
159<b>chart.background.barcolor1</b><br />
160            The color of the background bars. <br /><i>Default: rgba(0,0,0,0)</i><br /><br />
161            <a name="chart.background.barcolor2"></a>
162<b>chart.background.barcolor2</b><br />
163            The color of the background bars. <br /><i>Default: rgba(0,0,0,0)</i><br /><br />
164            <a name="chart.background.grid"></a>
165<b>chart.background.grid</b><br />
166            Whether to show the background grid or not. <br /><i>Default: true</i><br /><br />
167            <a name="chart.background.grid.color"></a>
168<b>chart.background.grid.color</b><br />
169            The color of the background grid. <br /><i>Default: #eee</i><br /><br />
170           
171            <a name="chart.background.hbars"></a>
172            <b>chart.background.hbars</b><br />
173            An array of information stipulating horizontal coloured bars. You can use these to indicate limits. Eg:
174           
175            <pre class="code">myScatter.Set('chart.background.hbars', [[75, 10, 'yellow'], [85, 15, 'red']]);</pre>
176           
177            This would give you two bars, one red and a lower yellow bar. The units correspond to your scale, and are the
178            starting point and the height.<br />
179            <i>Default: null</i><br /><br />
180           
181            <b>chart.background.vbars</b><br />
182            An array of vertical bar information. They're specified like his:
183            <pre class="code">myScatter.Set('chart.background.vbars', [[0, 181, 'rgba(0,255,0,0.5)']]);</pre>           
184            <i>Default: null</i><br /><br />
185
186            <a name="chart.background.grid.border"></a>
187<b>chart.background.grid.border</b><br />
188            Determines whether a border line is drawn around the grid.<br /><i>Default: true</i><br /><br />
189            <a name="chart.background.grid.hlines"></a>
190<b>chart.background.grid.hlines</b><br />
191            Determines whether to draw the horizontal grid lines.<br /><i>Default: true</i><br /><br />
192            <a name="chart.background.grid.vlines"></a>
193<b>chart.background.grid.vlines</b><br />
194            Determines whether to draw the vertical grid lines.<br /><i>Default: true</i><br /><br />
195            <a name="chart.background.grid.autofit"></a>
196<b>chart.background.grid.autofit</b><br />
197            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 />
198            <a name="chart.background.grid.autofit.numhlines"></a>
199<b>chart.background.grid.autofit.numhlines</b><br />
200            When using autofit this allows you to specify how many horizontal grid lines you want. <br /><i>Default: 7</i><br /><br />
201           
202            <a name="chart.background.grid.autofit.numvlines"></a>
203            <b>chart.background.grid.autofit.numvlines</b><br />
204            When using autofit this allows you to specify how many vertical grid lines you want. <br />
205            <i>Default: 20</i><br /><br />
206
207            <a name="chart.background.grid.autofit.align"></a>
208            <b>chart.background.grid.autofit.align</b><br />
209            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
210            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 />
211            <i>Default: false</i><br /><br />
212           
213            <a name="chart.background.image"></a>
214            <b>chart.background.image</b><br />
215            If you want to specify a background image to use on your chart, specify it with this property.<br />
216            <i>Default: null</i><br /><br />
217
218<a name="labels and text"></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">Labels and text</h3>
220   
221    <a name="chart.labels"></a>
222    <b>chart.labels</b><br />
223    An array of the X labels for the chart. <br />
224    <i>Default: [] (An empty array)</i><br /><br />
225   
226    <a name="chart.labels.above"></a>
227    <b>chart.labels.above</b><br />
228    If true this will show the values of the points above them.<br />
229    <i>Default: false</i><br /><br />
230   
231    <a name="chart.labels.above.size"></a>
232    <b>chart.labels.above.size</b><br />
233    If you're showing the labels above the points, this controls their size.<br />
234    <i>Default: 8</i><br /><br />
235   
236    <a name="chart.labels.avove.decimals"></a>
237    <b>chart.labels.above.decimals</b><br />
238    If your points have lots of decimals, you use this option to curtail them.<br />
239    <i>Default: 0</i><br /><br />
240   
241    <a name="chart.ylabels"></a>
242<b>chart.ylabels</b><br />
243            A boolean (<i>true</i> or <i>false</i>) that controls whether the chart has Y labels. <br /><i>Default: true</i><br /><br />
244           
245            <a name="chart.ylabels.count"></a>
246            <b>chart.ylabels.count</b><br />
247            A value (<i>1, 3, 5 or 10</i>) that controls how many Y labels there are. <br />
248            <i>Default: 5</i><br /><br />
249           
250            <a name="chart.ylabels.invert"></a>
251            <b>chart.ylabels.invert</b><br />
252            Reverses the Y axis so that 0 is at the top, instead of the bottom.<br />
253            <i>Default: false</i><br /><br />
254
255            <a name="chart.ylabels.specific"></a>
256            <b>chart.ylabels.specific</b><br />
257            You can use this option to give your own Y labels (eg ['Low', 'Medium', 'High'].<br />
258            <i>Default: null</i><br /><br />
259
260            <a name="chart.text.font"></a>
261<b>chart.text.font</b><br />
262            The font used to render the text.<br /><i>Default: Verdana</i><br /><br />
263           
264            <a name="chart.text.color"></a>
265            <b>chart.text.color</b><br />
266            The color of the labels. <br />
267            <i>Default: black</i><br /><br />
268           
269            <a name="chart.text.size"></a>
270            <b>chart.text.size</b><br />
271            The size of the text (in points).<br />
272            <i>Default: 10</i><br /><br />
273
274            <a name="chart.text.angle"></a>
275            <b>chart.text.angle</b><br />
276            The angle of the horizontal text labels (at the bottom of the chart). This can be from 0-90 (degrees)<br />
277            <i>Default: 0 (Horizontal)</i><br /><br />
278
279            <a name="chart.labels.specific.align"></a>
280            <b>chart.labels.specific.align</b><br />
281            If you are using specific points for X labels, by default the labels are left aligned within its section. With this setting
282            you can center the labels within its section.<br />
283            <i>Default: left</i><br /><br />
284<!--
285            <a name="chart.text.halign"></a>
286            <b>chart.text.halign</b><br />
287            This only affects X labels when you're using specific X points, and controls the alignment in the labels
288            individual "section".<br />
289            <i>Default: left</i><br /><br />
290-->
291<a name="margins"></a>
292<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>
293
294
295
296            <a name="chart.gutter.left"></a>
297            <b>chart.gutter.left</b><br />
298            The left gutter of the chart, (the gutter is where the labels and title are)).<br />
299            <i>Default: 25</i><br /><br />
300
301            <a name="chart.gutter.right"></a>
302            <b>chart.gutter.right</b><br />
303            The right gutter of the chart, (the gutter is where the labels and title are).<br />
304            <i>Default: 25</i><br /><br />
305
306            <a name="chart.gutter.top"></a>
307            <b>chart.gutter.top</b><br />
308            The top gutter of the chart, (the gutter is where the labels and title are).<br />
309            <i>Default: 25</i><br /><br />
310
311            <a name="chart.gutter.bottom"></a>
312            <b>chart.gutter.bottom</b><br />
313            The bottom gutter of the chart, (the gutter is where the labels and title are).<br />
314            <i>Default: 25</i><br /><br />
315
316<a name="axis properties"></a>
317<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">Axis properties</h3>            <a name="chart.xmax"></a>
318<b>chart.xmax</b><br />
319            The maximum X axis value you wish to set. For example if you're displaying products sold in a year, you might use 365. <br /><i>Default: none - must be supplied</i><br /><br />
320            <a name="chart.ymax"></a>
321<b>chart.ymax</b><br />
322            The optional maximum Y scale value. If not specified then it will be calculated.<br /><i>Default: null (It's calculated)</i><br /><br />
323            <a name="chart.ymin"></a>
324<b>chart.ymin</b><br />
325            The optional minimum Y scale value. If not specified it will be zero.<br /><i>Default: null</i><br /><br />
326            <a name="chart.ticksize"></a>
327<b>chart.ticksize</b><br />
328            The size of the tickmarks. <br /><i>Default: 3</i><br /><br />
329            <a name="chart.tickmarks"></a>
330<b>chart.tickmarks</b><br />
331            The style of the tickmarks. Can be: <i>cross</i>, <i>plus</i>, <i>circle</i>, <i>diamond</i>, <i>square</i> or <i>null</i> (no tickmarks). <br /><i>Default: cross</i><br /><br />
332            <a name="chart.xticks"></a>
333<b>chart.xticks</b><br />
334            This controls whether the X axis tickmarks are drawn.<br /><i>Default: true</i><br /><br />
335            <a name="chart.xaxispos"></a>
336<b>chart.noendxtick</b><br />
337            Whether to draw an end X tick. Usually used when combining Scatter charts<br /><i>Default: false</i><br /><br />
338            <a name="chart.xaxispos"></a>
339<b>chart.xaxis</b><br />
340            This controls whether the X axis is drawn.<br /><i>Default: true</i><br /><br />
341            <a name="chart.xaxispos"></a>
342<b>chart.xaxispos</b><br />
343            Where the X axis should be drawn. Can be either <i>center</i> or <i>bottom</i>.<br /><i>Default: bottom</i><br /><br />
344            <a name="chart.yaxispos"></a>
345<b>chart.yaxispos</b><br />
346            Where the Y axis should be drawn. Can be either <i>left</i> or <i>right</i>.<br /><i>Default: left</i><br /><br />
347            <a name="chart.axis.color"></a>
348<b>chart.axis.color</b><br />
349            The color of the axes.<br /><i>Default: black</i><br /><br />
350            <a name="chart.noaxes"></a>
351<b>chart.noaxes</b><br />
352            If this is set to true, no axes will be drawn. <br /><i>Default: false</i><br /><br />
353<a name="titles"></a>
354<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>
355<b>chart.title</b><br />
356            The title of the scatter chart. <br /><i>Default: none</i><br /><br />
357
358<a name="chart.title.background"></a>
359<b>chart.title.background</b><br />
360The background color (if any) for the title.<br />
361<i>Default: null</i><br /><br />
362
363            <a name="chart.title.hpos"></a>
364<b>chart.title.hpos</b><br />
365            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 />
366            <a name="chart.title.vpos"></a>
367<b>chart.title.vpos</b><br />
368            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 />
369            <a name="chart.title.color"></a>
370<b>chart.title.color</b><br />
371            The color of the title.<br /> <i>Default: black</i><br /><br />
372            <a name="chart.title.xaxis"></a>
373<b>chart.title.xaxis</b><br />
374            This allows to specify a title for the X axis.<br /><i>Default: none</i><br /><br />
375            <a name="chart.title.yaxis"></a>
376<b>chart.title.yaxis</b><br />
377            This allows to specify a title for the Y axis.<br /><i>Default: none</i><br /><br />
378            <a name="chart.title.xaxis.pos"></a>
379<b>chart.title.xaxis.pos</b><br />
380            This is multiplied with the gutter to give the position of the X axis title.<br /><i>Default: 0.25</i><br /><br />
381            <a name="chart.title.yaxis.pos"></a>
382<b>chart.title.yaxis.pos</b><br />
383            This is multiplied with the gutter to give the position of the Y axis title.<br /><i>Default: 0.25</i><br /><br />
384
385            <a name="chart.title.yaxis.position"></a>
386            <b>chart.title.yaxis.position</b><br />
387            Instead of using the option above you can instead use this option, specifying <i>left</i> or <i>right</i>.<br />
388            <i>Default: left</i><br /><br />
389
390<a name="scale"></a>
391<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>
392
393<a name="chart.scale.formatter"></a>
394            <b>chart.scale.formatter</b><br />
395            To allow thoroughly custom formats of numbers in the scale, you can use this option to
396            specify a function that is used by RGraph to format numbers. This function should
397            handle ALL of the formatting. Eg:<br /><br />
398            <pre class="code">
399function myFormatter(obj, num)
400{
401    return num + 'F'; // An example of formatting
402}
403myGraph.Set('chart.scale.formatter', myFormatter);
404</pre>
405            <br /><i>Default: null</i><br /><br />
406
407<a name="chart.scale.decimals"></a>
408<b>chart.scale.decimals</b><br />
409            The number of decimal places to display for the Y scale.<br /><i>Default: 0</i><br /><br />
410            <a name="chart.scale.point"></a>
411<b>chart.scale.point</b><br />
412            The character used as the decimal point.<br /><i>Default: .</i><br /><br />
413            <a name="chart.scale.thousand"></a>
414<b>chart.scale.thousand</b><br />
415            The character used as the thousand separator<br /><i>Default: ,</i><br /><br />
416
417            <a name="chart.scale.round"></a>
418            <b>chart.scale.round</b><br />
419            Whether to round the maximum scale value up or not. This will produce slightly better scales in some instances.<br />
420            <i>Default: null</i><br /><br />
421
422            <a name="chart.units.pre"></a>
423<b>chart.units.pre</b><br />
424            The units (if any) that the Y axis is measured in (these are preppended to the number).<br /><i>Default: none</i><br /><br />
425            <a name="chart.units.post"></a>
426<b>chart.units.post</b><br />
427            The units (if any) that the Y axis is measured in (these are appended to the number).<br /><i>Default: none</i><br /><br />
428
429<a name="interactive features"></a>
430<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>
431
432    <p style="background-color: #ffe; padding: 3px; border: 1px black solid; border-radius: 5px">
433        <b>Note:</b> Unlike other charts, the Scatter chart tooltips are specified as part of the data array. See <a href="#top">above</a>.
434    </p>
435
436    <a name="chart.tooltips.effect"></a>
437    <b>chart.tooltips.effect</b><br />
438    The animated effect used for showing tooltips.<br />
439    <i>Default: fade</i><br /><br />
440   
441            <a name="chart.tooltips.hotspot"></a>
442            <b>chart.tooltips.hotspot</b><br />
443            This controls the size of the hotspot on the chart for tooltips.<br /><i>Default: 3</i><br /><br />
444            <a name="chart.tooltips.css.class"></a>
445           
446            <a name="chart.tooltips.highlight"></a>
447            <b>chart.tooltips.highlight</b><br />
448            This controls whether points are highlighted when a tooltip is shown. If you're combining the Scatter with another chart
449            you may need to set this to <i>false</i>.<br />
450            <i>Default: true</i><br /><br />
451           
452            <a name="chart.tooltips.css.class"></a>
453            <b>chart.tooltips.css.class</b><br />
454            This is the name of the CSS class the chart uses.<br /><i>Default: RGraph_tooltip</i><br /><br />
455           
456            <a name="chart.tooltips.override"></a>
457            <b>chart.tooltips.override</b><br />
458            If you wish to handle showing tooltips yourself, this should be a function object which does just that. There's more
459            information on the <a href="tooltips.html">tooltips documentation page</a><br />
460            <i>Default: null</i><br /><br />
461
462            <a name="chart.crosshairs"></a>
463<b>chart.crosshairs</b><br />
464            If true, you will get a crosshair centering on the current mouse position.<br /><i>Default: false</i><br /><br />
465            <a name="chart.crosshairs.linewidth"></a>
466<b>chart.crosshairs.linewidth</b><br />
467            This controls the linewidth of the crosshairs.<br /><i>Default: 1</i><br /><br />
468            <a name="chart.crosshairs.color"></a>
469<b>chart.crosshairs.color</b><br />
470            The color of the crosshairs.<br /><i>Default: #333</i><br /><br />
471            <a name="chart.crosshairs.coords"></a>
472<b>chart.crosshairs.coords</b><br />
473            If true, this will show the coordinates that the crosshairs are currently over.<br /><i>Default: false</i><br /><br />
474            <a name="chart.crosshairs.fixed"></a>
475<b>chart.crosshairs.fixed</b><br />
476            If true, this makes the coordinates static (attached), instead of following the pointer around.<br /><i>Default: false</i><br /><br />
477            <a name="chart.crosshairs.fadeout"></a>
478<b>chart.crosshairs.fadeout</b><br />
479            If true, when you move your mouse off of the canvas the coordinates will fade out.<br /><i>Default: false</i><br /><br />
480            <a name="chart.crosshairs.labels.x"></a>
481<b>chart.crosshairs.labels.x</b><br />
482            Instead ox X and Y, you can specify more meaningful labels.<br /><i>Default: X</i><br /><br />
483            <a name="chart.crosshairs.labels.y"></a>
484<b>chart.crosshairs.labels.y</b><br />
485            Instead ox X and Y, you can specify more meaningful labels.<br /><i>Default: Y</i><br /><br />
486            <a name="chart.contextmenu"></a>
487<b>chart.contextmenu</b><br />
488            An array of context menu items. More information on context menus is <a href="context.html">here</a>.<br /><i>Default: null</i><br /><br />
489            <a name="chart.annotatable"></a>
490<b>chart.annotatable</b><br />
491            Whether annotations are enabled for the chart (ie you can draw on the chart interactively.<br /><i>Default: false</i><br /><br />
492            <a name="chart.annotate.color"></a>
493<b>chart.annotate.color</b><br />
494            If you do not allow the use of the palette, then this will be the only colour allowed for annotations.<br /><i>Default: #000</i><br /><br />
495
496
497            <a name="chart.resizable"></a>
498            <b>chart.resizable</b><br />
499            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 />
500            <i>Default: false</i><br /><br />
501
502
503            <a name="chart.resize.handle.background"></a>
504            <b>chart.resize.handle.background</b><br />
505            With this you can specify the background color for the resize handle. If you're adjusting the position of the
506            handle then you may need this to make the handle stand out more.<br />
507            <i>Default: null</i><br /><br />
508
509<a name="line properties"></a>
510<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">Line properties</h3>            <a name="chart.line"></a>
511<b>chart.line</b><br />
512            Whether to show a connecting line (like in the sixth example). <br /><i>Default: false</i><br /><br />
513            <a name="chart.line.colors"></a>
514<b>chart.line.colors</b><br />
515            The colors of the lines connecting the tick marks. <br /><i>Default: ['green', 'red']</i><br /><br />
516            <a name="chart.line.shadow.color"></a>
517<b>chart.line.shadow.color</b><br />
518            The color of the lines shadow (if any). <br /><i>Default: rgba(0,0,0,0) (invisible)</i><br /><br />
519            <a name="chart.line.shadow.offsetx"></a>
520<b>chart.line.shadow.offsetx</b><br />
521            The X offset of the lines shadow. <br /><i>Default: 3</i><br /><br />
522            <a name="chart.line.shadow.offsety"></a>
523<b>chart.line.shadow.offsety</b><br />
524            The Y offset of the lines shadow. <br /><i>Default: 3</i><br /><br />
525            <a name="chart.line.shadow.blur"></a>
526<b>chart.line.shadow.blur</b><br />
527            The severity of the line shadows blurring effect. <br /><i>Default: 2</i><br /><br />
528            <a name="chart.line.stepped"></a>
529<b>chart.line.stepped</b><br />
530            Like the line chart, Scatter chart lines can be stepped by setting this to true <br /><i>Default: false</i><br /><br />
531
532
533
534
535            <a name="key"></a>
536            <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>
537           
538            <a name="chart.key"></a>
539            <b>chart.key</b><br />
540            An array of key information. <br />
541            <i>Default: [] (An empty array)</i><br /><br />
542
543            <a name="chart.key.background"></a>
544            <b>chart.key.background</b><br />
545            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>
546            <i>Default: white</i><br /><br />
547           
548            <a name="chart.key.halign"></a>
549            <b>chart.key.halign</b><br />
550            Instead of specifying the exact x/y coordinates, you can use this property to simply specify whether the key hould be
551            aligned <i>left</i> or <i>right</i>.<br />
552            <i>Default: right</i><br /><br />
553           
554            <a name="chart.key.position"></a>
555            <b>chart.key.position</b><br />
556            Determines the position of the key.Either <b>graph</b> (default), or <b>gutter</b>.<br />
557            <i>Default: graph</i><br /><br />
558           
559            <b>chart.key.position.x</b><br />
560            This allows you to specify a specific X coordinate for the key.<br />
561            <i>Default: null</i><br /><br />
562           
563            <b>chart.key.position.y</b><br />
564            This allows you to specify a specific Y coordinate for the key.<br />
565            <i>Default: null</i><br /><br />
566           
567            <b>chart.key.position.gutter.boxed</b><br />
568            If you have the key in gutter mode (ie horizontal), this allows you to give a background color.<br />
569            <i>Default: true</i><br /><br />
570           
571            <a name="chart.key.shadow"></a>
572            <b>chart.key.shadow</b><br />
573            Whether a small drop shadow is applied to the key.<br />
574            <i>Default: false</i><br /><br />
575
576            <a name="chart.key.shadow.color"></a>
577            <b>chart.key.shadow.color</b><br />
578            The color of the shadow.<br />
579            <i>Default: #666</i><br /><br />
580
581            <a name="chart.key.shadow.blur"></a>
582            <b>chart.key.shadow.blur</b><br />
583            The extent of the blurring effect used on the shadow.<br />
584            <i>Default: 3</i><br /><br />
585
586            <a name="chart.key.shadow.offsetx"></a>
587            <b>chart.key.shadow.offsetx</b><br />
588            The X offset of the shadow.<br />
589            <i>Default: 2</i><br /><br />
590
591            <a name="chart.key.shadow.offsety"></a>
592            <b>chart.key.shadow.offsety</b><br />
593            The Y offset of the shadow.<br />
594            <i>Default: 2</i><br /><br />
595
596            <b>chart.key.rounded</b><br />
597            This controls whether the corners of the key (in graph mode) are curved. If the key is gutter mode, this has no effect.<br />
598            <i>Default: false</i><br /><br />
599           
600            <b>chart.key.color.shape</b><br />
601            This can be <i>square</i>, <i>circle</i> or <i>line</i> and controls how the color indicators in the key appear.<br />
602            <i>Default: square</i><br /><br />
603           
604            <b>chart.key.linewidth</b><br />
605            The line width of the surrounding border on the key.<br />
606            <i>Default: 1</i><br /><br />
607
608
609
610
611
612<a name="zoom"></a>
613<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>
614<b>chart.zoom.mode</b><br />
615            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 />
616            <a name="chart.zoom.factor"></a>
617<b>chart.zoom.factor</b><br />
618            This is the factor that the chart will be zoomed by (bigger values means more zoom)<br /><i>Default: 1.5</i><br /><br />
619            <a name="chart.zoom.fade.in"></a>
620<b>chart.zoom.fade.in</b><br />
621            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 />
622            <a name="chart.zoom.fade.out"></a>
623<b>chart.zoom.fade.out</b><br />
624            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 />
625            <a name="chart.zoom.hdir"></a>
626<b>chart.zoom.hdir</b><br />
627            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 />
628            <a name="chart.zoom.vdir"></a>
629<b>chart.zoom.vdir</b><br />
630            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 />
631            <a name="chart.zoom.delay"></a>
632<b>chart.zoom.delay</b><br />
633            The delay (in milliseconds) between frames.<br /><i>Default: 50</i><br /><br />
634            <a name="chart.zoom.frames"></a>
635<b>chart.zoom.frames</b><br />
636            The number of frames in the zoom animation.<br /><i>Default: 10</i><br /><br />
637            <a name="chart.zoom.shadow"></a>
638<b>chart.zoom.shadow</b><br />
639            Whether or not the zoomed canvas has a shadow or not.<br /><i>Default: true</i><br /><br />
640            <a name="chart.zoom.thumbnail.width"></a>
641<b>chart.zoom.thumbnail.width</b><br />
642            When the zoom is in thumbnail mode, this is the width (in pixels) of the thumbnail.<br /><i>Default: 75</i><br /><br />
643            <a name="chart.zoom.thumbnail.height"></a>
644<b>chart.zoom.thumbnail.height</b><br />
645            When the zoom is in thumbnail mode, this is the height (in pixels) of the thumbnail.<br /><i>Default: 75</i><br /><br />
646            <a name="chart.zoom.background"></a>
647<b>chart.zoom.background</b><br />
648            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 />
649<a name="miscellaneous"></a>
650<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.defaultcolor"></a>
651<b>chart.defaultcolor</b><br />
652            This is the default color of tick marks, which is used if a color isn't given.<br /><i>Default: #000</i><br /><br />
653            <a name="chart.boxplot.width"></a>
654<b>chart.boxplot.width</b><br />
655            This stipulates the default width of boxes. For more on boxplots, see <a href="#boxplots">here</a>.<br /><i>Default: 8</i><br /><br />
656</div><!-- /DOCS --><br /><br />
657
658    <a name="methods"></a>
659    <h2>Methods</h2>
660   
661    <b>obj.getPoint(e)</b>
662   
663    <p>
664        This method makes it easier to get hold of which point on the Scatter chart has been hovered over. It returns an array of:
665    </p>
666   
667    <ul>
668        <li>The X coordinate of the point</li>
669        <li>The Y coordinate of the point</li>
670        <li>The data set. This corresponds to the appropriate dataset (since mutiple datasets can be given to the constructor)</li>
671        <li>The index of the appropriate data point in the set</li>
672        <li>The tooltip (if any) for that particular point</li>
673    </ul>
674   
675    (If the return value is null, then no point is being hovered over.) An example usage is:
676   
677    <pre class="code">
678&lt;script src="RGraph.common.core.js"&gt;&lt;/script&gt;
679&lt;script src="RGraph.line.js"&gt;&lt;/script&gt;
680
681&lt;canvas id="cvs" width="600" height="250" style="border: 1px gray dashed"&gt;[No canvas support]&lt;/canvas&gt;
682
683&lt;script&gt;
684    scatter = new RGraph.Scatter('cvs', [[5,1, 'red', 'A'],[4,2,, 'B'],[3,9,,'C'],[10,12,,'D'],[300,2,,'E']],
685                                        [[5,6, 'red', 'F'],[2,9,,'G'],[13,19,,'H'],[18,17,,'I'],[340,12,,'J']]);
686    scatter.Set('chart.xmax', 365);
687    scatter.Set('chart.line', true);
688    scatter.Set('chart.labels', ['Q1', 'Q2', 'Q3', 'Q4']);
689    scatter.Draw();
690
691    scatter.canvas.onmousemove = function (e)
692    {
693        var canvas  = e.target;
694        var context = canvas.getContext('2d');
695        var obj     = canvas.__object__;
696        var point   = obj.getPoint(e);
697
698        if (point) {
699            p('\r\nX Coordinate: ' + point[0] + '\r\n' +
700              'Y Coordinate: ' + point[1] + '\r\n' +
701              'Dataset: ' + point[2] + '\r\n' +
702              'Datapoint: ' + point[3] + '\r\n' +
703              'Tooltip: ' + point[4] + '\r\n');
704        }
705    }
706&lt;/script&gt;
707</pre>
708
709    <a name="boxplots"></a>
710    <h2>Box plots</h2>
711   
712    <p>
713        Instead of a single Y value, you have the ability to specify an array of 5, 6, 7 or 8 values, which will be used to make a box plot.
714        The <a href="../examples/scatter.html#boxplots">example page shows a box plot</a>. These values are (in order):
715
716        <ul>
717            <li>Lower whisker</li>
718            <li>Bottom of box</li>
719            <li>Middle value (which isn't necessarily in the center of the box - this depends on your data)</li>
720            <li>Top of box</li>
721            <li>Upper whisker</li>
722            <li>Upper color (optional)</li>
723            <li>Lower color (optional)</li>
724            <li>Width (optional)</li>
725        </ul>
726
727        <pre class="code">
728&lt;script&gt;
729    scatter8 = new RGraph.Scatter('scatter8', [
730                                               [10,<span style="color: green">[1,1,16,24,24, 'red', 'green']</span>],
731                                               [105,<span style="color: green">[5,10,15,25,25, 'red', 'green']</span>],
732                                               [125,<span style="color: green">[10,15,25,35,45, 'red', 'green']</span>],
733                                               [325,<span style="color: green">[10,15,25,35,45, 'red', 'green', 30]</span>]
734                                              ]);
735    scatter8.Set('chart.title', 'An example of a boxplot');
736    scatter8.Set('chart.labels', ['Q1', 'Q2', 'Q3', 'Q4']);
737    scatter8.Set('chart.xmax', 365);
738    scatter8.Set('chart.ymax', 50);
739    scatter8.Set('chart.boxplot.width', 12); // The default width
740    scatter8.Draw();
741&lt;/script&gt;
742</pre>
743    </p>
744
745
746    <a name="labelpoints"></a>
747    <h2>Specific points for labels on the X axis</h2>
748   
749    <p>
750        Instead of a simple string which is used as the label, each entry of the chart.labels array can be a two element array
751        consisting of the label, and the X value that the label should be placed at. For example:
752    </p>
753
754    <pre class="code">
755scatter.Set('chart.labels', [
756                             ['Quarter 1', 0],
757                             ['Quarter 2', 90],
758                             ['Quarter 3', 181],
759                             ['Quarter 4', 273]
760                            ]);
761</pre>
762
763
764
765    <a name="custom.tickmarks"></a>
766    <h2>Custom tickmarks</h2>
767
768    <p>
769        If none of the available tickmark styles are suitable, you can instead specify a function object that draws the tickmark,
770        enabling you to draw the tickmark yourself. For example:
771    </p>
772
773    <pre class="code">
774&lt;script&gt;
775    line.Set('chart.tickmarks', myTick);
776
777    /**
778    * The function that is called once per tickmark, to draw it
779    *
780    * @param object obj   The chart object
781    * @param object data  The chart data
782    * @param number x     The X coordinate
783    * @param number y     The Y coordinate
784    * @param number xVal  The X value
785    * @param number yVal  The Y value
786    * @param number xMax  The maximum X scale value
787    * @param number xMax  The maximum Y scale value
788    * @param string color The color of the tickmark
789    */
790    function myTick (obj, data, x, y, xVal, yVal, xMax, yMax, color)
791    {
792        // Draw your custom tick here
793    }
794&lt;/script&gt;
795</pre>
796
797    <a name="colors"></a>
798    <h2>Note about colors and the key</h2>
799   
800    <p>
801        If you're using a key you may need to set <i>chart.line.colors</i> to allow it to use the correct colors. For example:
802    </p>
803   
804    <pre class="code">myObj.Set('chart.line.colors', ['red','green','blue']);</pre>
805</body>
806</html>
Note: See TracBrowser for help on using the repository browser.