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 | /** |
---|
9 | * o------------------------------------------------------------------------------o |
---|
10 | * | This file is part of the RGraph package - you can learn more at: | |
---|
11 | * | | |
---|
12 | * | http://www.rgraph.net | |
---|
13 | * | | |
---|
14 | * | This package is licensed under the RGraph license. For all kinds of business | |
---|
15 | * | purposes there is a small one-time licensing fee to pay and for non | |
---|
16 | * | commercial purposes it is free to use. You can read the full license here: | |
---|
17 | * | | |
---|
18 | * | http://www.rgraph.net/LICENSE.txt | |
---|
19 | * o------------------------------------------------------------------------------o |
---|
20 | */ |
---|
21 | --> |
---|
22 | <title>RGraph: Javascript charts and graph library - bar charts</title> |
---|
23 | |
---|
24 | <meta name="keywords" content="rgraph html5 canvas example bar charts" /> |
---|
25 | <meta name="description" content="RGraph: Javascript charts and graph library - Bar charts example" /> |
---|
26 | |
---|
27 | <meta property="og:title" content="RGraph: Javascript charts and graph library" /> |
---|
28 | <meta property="og:description" content="A javascript charts library based on the HTML5 canvas tag" /> |
---|
29 | <meta property="og:image" content="http://www.rgraph.net/images/logo.png"/> |
---|
30 | |
---|
31 | <link rel="stylesheet" href="../css/website.css" type="text/css" media="screen" /> |
---|
32 | <link rel="icon" type="image/png" href="../images/favicon.png"> |
---|
33 | |
---|
34 | <script src="../libraries/RGraph.common.core.js" ></script> |
---|
35 | <script src="../libraries/RGraph.common.annotate.js" ></script> |
---|
36 | <script src="../libraries/RGraph.common.context.js" ></script> |
---|
37 | |
---|
38 | <script src="../libraries/RGraph.common.tooltips.js" ></script> |
---|
39 | <script src="../libraries/RGraph.common.resizing.js" ></script> |
---|
40 | <script src="../libraries/RGraph.bar.js" ></script> |
---|
41 | <!--[if IE 8]><script src="../excanvas/excanvas.original.js"></script><![endif]--> |
---|
42 | |
---|
43 | <script> |
---|
44 | /** |
---|
45 | * The onload function creates the graph |
---|
46 | */ |
---|
47 | window.onload = function () |
---|
48 | { |
---|
49 | |
---|
50 | var bar1 = new RGraph.Bar('bar1', [ |
---|
51 | [0.000092, 0.00008], |
---|
52 | [0.000034, 0.000057], |
---|
53 | [0.000056, 0.000062], |
---|
54 | [0.000055, 0.000045], |
---|
55 | [0.000036, 0.000012], |
---|
56 | [0.000044, 0.000056], |
---|
57 | [0.000051, 0.000066], |
---|
58 | [0.000068, 0.000088]]); |
---|
59 | bar1.Set('chart.background.barcolor1', 'white'); |
---|
60 | bar1.Set('chart.background.barcolor2', 'white'); |
---|
61 | bar1.Set('chart.labels', ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th']); |
---|
62 | bar1.Set('chart.key', ['John', 'Bob']); |
---|
63 | bar1.Set('chart.key.position.y', 35); |
---|
64 | bar1.Set('chart.key.position', 'gutter'); |
---|
65 | bar1.Set('chart.key.background', 'rgb(255,255,255)'); |
---|
66 | bar1.Set('chart.colors', ['#77f', '#7f7']); |
---|
67 | bar1.Set('chart.shadow', true); |
---|
68 | bar1.Set('chart.shadow.blur', 15); |
---|
69 | bar1.Set('chart.shadow.offsetx', 0); |
---|
70 | bar1.Set('chart.shadow.offsety', 0); |
---|
71 | bar1.Set('chart.shadow.color', '#aaa'); |
---|
72 | bar1.Set('chart.yaxispos', 'right'); |
---|
73 | bar1.Set('chart.strokestyle', 'rgba(0,0,0,0)'); |
---|
74 | bar1.Set('chart.gutter.left', 5); |
---|
75 | bar1.Set('chart.gutter.right', 45); |
---|
76 | bar1.Draw(); |
---|
77 | |
---|
78 | var bar2 = new RGraph.Bar('bar2', [[30,20,19,21], [23,25, 27, 30], [30,25,29, 32], [27,28,35,33], [26,18,29,30], [31,20,25,27], [39,28,28,35], [27,29,28,29], [26,23,26,27], [30,20,19,21], [30,20,19,21], [30,20,19,21]]); |
---|
79 | bar2.Set('chart.units.pre', '$'); |
---|
80 | bar2.Set('chart.title', 'Sales in the last 8 months (tooltips)'); |
---|
81 | bar2.Set('chart.title.vpos', 0.5); |
---|
82 | bar2.Set('chart.colors', ['red', 'yellow', 'green', 'orange']); |
---|
83 | bar2.Set('chart.gutter.left', 40); |
---|
84 | bar2.Set('chart.gutter.right', 5); |
---|
85 | bar2.Set('chart.gutter.top', 40); |
---|
86 | bar2.Set('chart.gutter.bottom', 50); |
---|
87 | bar2.Set('chart.shadow', true); |
---|
88 | bar2.Set('chart.shadow.color', '#aaa'); |
---|
89 | bar2.Set('chart.background.barcolor1', 'white'); |
---|
90 | bar2.Set('chart.background.barcolor2', 'white'); |
---|
91 | bar2.Set('chart.background.grid.hsize', 5); |
---|
92 | bar2.Set('chart.background.grid.vsize', 5); |
---|
93 | bar2.Set('chart.grouping', 'stacked'); |
---|
94 | bar2.Set('chart.labels', ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September','October','November','December']); |
---|
95 | bar2.Set('chart.labels.above', true); |
---|
96 | bar2.Set('chart.key', ['Richard', 'Barbara', 'Johnny', 'Frederick']); |
---|
97 | bar2.Set('chart.key.background', 'rgba(255,255,255,0.7)'); |
---|
98 | bar2.Set('chart.key.position', 'gutter'); |
---|
99 | bar2.Set('chart.key.position.gutter.boxed', false); |
---|
100 | bar2.Set('chart.key.position.y', bar2.Get('chart.gutter.top') - 15); |
---|
101 | bar2.Set('chart.key.border', false); |
---|
102 | bar2.Set('chart.background.grid.width', 0.3); // Decimals are permitted |
---|
103 | bar2.Set('chart.text.angle', 35); |
---|
104 | bar2.Set('chart.strokestyle', 'rgba(0,0,0,0)'); |
---|
105 | bar2.Set('chart.tooltips.event', 'onmousemove'); |
---|
106 | |
---|
107 | if (!RGraph.isIE8()) { |
---|
108 | tooltipFunc = function (i) |
---|
109 | { |
---|
110 | var r = i % 4; |
---|
111 | |
---|
112 | if (r == 3) return 'John' |
---|
113 | else if (r == 2) return 'Rich'; |
---|
114 | else if (r == 1) return 'Jane'; |
---|
115 | else if (r == 0) return 'Quentin'; |
---|
116 | } |
---|
117 | bar2.Set('chart.tooltips', tooltipFunc); |
---|
118 | } |
---|
119 | |
---|
120 | bar2.Draw(); |
---|
121 | } |
---|
122 | </script> |
---|
123 | |
---|
124 | <script> |
---|
125 | var _gaq = _gaq || []; |
---|
126 | _gaq.push(['_setAccount', 'UA-54706-2']); |
---|
127 | _gaq.push(['_trackPageview']); |
---|
128 | |
---|
129 | (function() { |
---|
130 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
---|
131 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
---|
132 | var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
---|
133 | })(); |
---|
134 | </script> |
---|
135 | </head> |
---|
136 | <body> |
---|
137 | <!-- Social networking buttons --> |
---|
138 | <div id="social_icons" class="warning" style="border-radius: 10px; top: 1px; position: fixed"> |
---|
139 | <a title="Bookmark with delicious" href="http://delicious.com/save?jump=close&v=4&noui&jump=close&url=http://www.rgraph.net¬es=RGraph%20is%20a%20HTML5%20based%20javascript%20charts%20library%20supporting%20a%20wide%20range%20of%20different%20charts%20types&title=RGraph:Javascript%20charts%20and%20graphs%20library" target="_blank"><img src="../images/delicious.png" alt="Bookmark with delicious" width="22" height="22" border="0" align="absmiddle" /></a> |
---|
140 | <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> |
---|
141 | </div> |
---|
142 | |
---|
143 | <script> |
---|
144 | // Opera fix |
---|
145 | if (navigator.userAgent.indexOf('Opera') == -1) { |
---|
146 | document.getElementById("social_icons").style.position = 'fixed'; |
---|
147 | } |
---|
148 | </script> |
---|
149 | <!-- Social networking buttons --> |
---|
150 | |
---|
151 | <div id="breadcrumb"> |
---|
152 | <a href="../index.html">RGraph: Javascript charts and graph library</a> |
---|
153 | > |
---|
154 | <a href="./index.html">Examples</a> |
---|
155 | > |
---|
156 | Bar charts |
---|
157 | </div> |
---|
158 | |
---|
159 | <h1>RGraph: <span>Javascript charts and graph library</span> - Bar charts</h1> |
---|
160 | |
---|
161 | <script> |
---|
162 | if (RGraph.isIE8()) { |
---|
163 | 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 graphs, 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>'); |
---|
164 | } |
---|
165 | </script> |
---|
166 | |
---|
167 | <div> |
---|
168 | <p> |
---|
169 | The bar chart is probably one of the most widely used of charts, and also one of the most versatile. It's defined as a chart with |
---|
170 | rectangular bars with lengths proportional to the values they represent. The bar chart can be used to represent two |
---|
171 | or more values. With grouped and stacked bar charts, you can visualise two or more sets of data. For example two years |
---|
172 | worth of sales figures. Doing this you will be able to easily see differences, for example a better year when it comes |
---|
173 | to sales. You can also show negative values by having the X axis in the center, like the examples shown. If you use a |
---|
174 | grouped or stacked bar chart, a key may be helpful to your users. |
---|
175 | </p> |
---|
176 | |
---|
177 | <p> |
---|
178 | By using the tooltips feature, you can provide more detail about what a particular bar represents. The tooltips in |
---|
179 | <b>RGraph</b> can contain wide range of HTML, so you can use them to show photos or movies for example. |
---|
180 | </p> |
---|
181 | |
---|
182 | <div> |
---|
183 | <ul> |
---|
184 | <li><a href="../docs/bar.html">Bar chart API documentation</a></li> |
---|
185 | </ul> |
---|
186 | </div> |
---|
187 | |
---|
188 | <div> |
---|
189 | <canvas id="bar1" width="450" height="200">[No canvas support]</canvas> |
---|
190 | <canvas id="bar2" width="450" height="200">[No canvas support]</canvas> |
---|
191 | </div> |
---|
192 | </div> |
---|
193 | |
---|
194 | </body> |
---|
195 | </html> |
---|