first commit
[wnstats.git] / public / javascripts / jqplot / examples / bubbleChart.html
blob628d906645404574522910247d7836bea4060025
1 <!DOCTYPE html>
3 <html>
4 <head>
6 <title>Bubble Charts</title>
8 <link class="include" rel="stylesheet" type="text/css" href="../jquery.jqplot.min.css" />
9 <link rel="stylesheet" type="text/css" href="examples.min.css" />
10 <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCoreDefault.min.css" />
11 <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemejqPlot.min.css" />
13 <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
14 <script class="include" type="text/javascript" src="../jquery.min.js"></script>
17 </head>
18 <body>
19 <div class="logo">
20 <div class="nav">
21 <a class="nav" href="../../../index.php"><span>&gt;</span>Home</a>
22 <a class="nav" href="../../../docs/"><span>&gt;</span>Docs</a>
23 <a class="nav" href="../../download/"><span>&gt;</span>Download</a>
24 <a class="nav" href="../../../info.php"><span>&gt;</span>Info</a>
25 <a class="nav" href="../../../donate.php"><span>&gt;</span>Donate</a>
26 </div>
27 </div>
28 <div class="example-content">
30 <div class="example-nav">
31 <a href="bubble-plots.html">Previous</a> <a href="./">Examples</a> <a href="candlestick-charts.html">Next</a></div>
34 <!-- Example scripts go here -->
36 <style type="text/css">
37 .jqplot-target {
38 margin-bottom: 2em;
41 .note {
42 font-size: 0.8em;
45 #tooltip1b {
46 font-size: 12px;
47 color: rgb(15%, 15%, 15%);
48 padding:2px;
49 background-color: rgba(95%, 95%, 95%, 0.8);
52 #legend1b {
53 font-size: 12px;
54 border: 1px solid #cdcdcd;
55 border-collapse: collapse;
57 #legend1b td, #legend1b th {
58 border: 1px solid #cdcdcd;
59 padding: 1px 4px;
61 </style>
64 <p>Bubble charts represent 3 dimensional data. Data is passed in to a bubble chart as a series of [x, y, radius, &lt;label or object&gt;]. The optional fourth element of the data point can either be either a label string or an object having 'label' and/or 'color' properties to assign to the bubble.</p>
66 <p>By default, all bubbles are scaled according to the size of the plot area. The radius value in the data point will be adjusted to fit the bubbles in the chart. If the "autoscaleBubbles" option is set to false, the radius value in the data will be taken as a literal pixel value for the radius of the points.</p>
68 <p>The below chart show basic customization of bubble appearance with the "bubbleAlpha" and "highlightAlpha" options.</p>
70 <div id="chart1" class="plot" style="width:460px;height:340px;"></div>
71 <pre class="code brush:js"></pre>
73 <div style="position:absolute;z-index:99;display:none;" id="tooltip1b"></div>
75 <table><tr>
76 <td><div id="chart1b" class="plot" style="width:460px;height:340px;"></div></td>
77 <td><div style="height:340px;"><table id="legend1b"><tr><th>Company</th><th>R Value</th></tr></table></div></td>
78 </tr></table>
79 <pre class="code brush:js"></pre>
81 <p>Below is a basic bubble chart showing usage of the optional label and color properties passed in with the data.</p>
83 <div id="chart1c" class="plot" style="width:460px;height:340px;"></div>
84 <pre class="code brush:js"></pre>
86 <p>The next chart uses the "bubbleGradients: true" option to specify gradient fills on the bubbles. Radial gradients are not supported in IE<sup>*</sup> and will be automatically disabled.</p>
88 <div id="chart2" class="plot" style="width:460px;height:340px;"></div>
90 <p class="note"><sup>*</sup>Radial gradients are not supported in IE 7 and IE 8 because they are not supported in the excanvas emulation layer used by jqPlot to render charts in IE 7 and IE 8. jqPlot renders charts using the HTML canvas element which is supported by nearly every browser including IE 9. Excanvas translates the canvas rendering to VML rendering for IE 7 and 8, but unfortunately does not properly handle radial gradients.</p>
92 <pre class="code brush:js"></pre>
94 <p>The following bubble chart shows the "autoscalePointsFactor" and "autoscaleMultiplier" options which can be used to control bubble scaling. The "autoscalePointsFactor" options controls bubble scaling with the number of points on the plot. A negative value will decrease bubble size and number of bubbles increases. The "autoscaleMultiplier" will makes all bubbles larger or smaller for values greater or less than 1.0.</p>
96 <p>This chart also demonstrates some of the highlighting options. Bubble highlighting is controlled with the "highlightMouseOver" and "highlightMouseDown" boolean options. Here the "highlightMouseDown: true" option is set which causes the plot to highlight on mousedown (click). This automatically sets the "highlightMouseOver" option to false.</p>
98 <p>Events are also trigger with plot interaction. Specifically, "jqplotDataHighlight", "jqplotDataUnhighlight", "jqplotDataClick" and "jqplotDataRightClick" events are triggered. Handlers are passed an event object, the series index, the point index, and the bubble data.</p>
100 <div id="chart3" class="plot" style="width:600px;height:400px;"></div>
101 <pre class="code brush:js"></pre>
103 <script class="code" language="javascript" type="text/javascript">$(document).ready(function(){
105 var arr = [[11, 123, 1236, "Acura"], [45, 92, 1067, "Alfa Romeo"],
106 [24, 104, 1176, "AM General"], [50, 23, 610, "Aston Martin Lagonda"],
107 [18, 17, 539, "Audi"], [7, 89, 864, "BMW"], [2, 13, 1026, "Bugatti"]];
109 plot1 = $.jqplot('chart1',[arr],{
110 title: 'Transparent Bubbles',
111 seriesDefaults:{
112 renderer: $.jqplot.BubbleRenderer,
113 rendererOptions: {
114 bubbleAlpha: 0.6,
115 highlightAlpha: 0.8
117 shadow: true,
118 shadowAlpha: 0.05
120 });
121 });</script>
123 <script class="code" language="javascript" type="text/javascript">$(document).ready(function(){
125 var arr = [[11, 123, 1236, "Acura"], [45, 92, 1067, "Alfa Romeo"],
126 [24, 104, 1176, "AM General"], [50, 23, 610, "Aston Martin Lagonda"],
127 [18, 17, 539, "Audi"], [7, 89, 864, "BMW"], [2, 13, 1026, "Bugatti"]];
129 plot1b = $.jqplot('chart1b',[arr],{
130 title: 'Tooltip and Custom Legend Highlighting',
131 seriesDefaults:{
132 renderer: $.jqplot.BubbleRenderer,
133 rendererOptions: {
134 bubbleAlpha: 0.6,
135 highlightAlpha: 0.8,
136 showLabels: false
138 shadow: true,
139 shadowAlpha: 0.05
143 // Legend is a simple table in the html.
144 // Now populate it with the labels from each data value.
145 $.each(arr, function(index, val) {
146 $('#legend1b').append('<tr><td>'+val[3]+'</td><td>'+val[2]+'</td></tr>');
149 // Now bind function to the highlight event to show the tooltip
150 // and highlight the row in the legend.
151 $('#chart1b').bind('jqplotDataHighlight',
152 function (ev, seriesIndex, pointIndex, data, radius) {
153 var chart_left = $('#chart1b').offset().left,
154 chart_top = $('#chart1b').offset().top,
155 x = plot1b.axes.xaxis.u2p(data[0]), // convert x axis unita to pixels on grid
156 y = plot1b.axes.yaxis.u2p(data[1]); // convert y axis units to pixels on grid
157 var color = 'rgb(50%,50%,100%)';
158 $('#tooltip1b').css({left:chart_left+x+radius+5, top:chart_top+y});
159 $('#tooltip1b').html('<span style="font-size:14px;font-weight:bold;color:'+color+';">' +
160 data[3] + '</span><br />' + 'x: '+data[0] + '<br />' + 'y: ' +
161 data[1] + '<br />' + 'r: ' + data[2]);
162 $('#tooltip1b').show();
163 $('#legend1b tr').css('background-color', '#ffffff');
164 $('#legend1b tr').eq(pointIndex+1).css('background-color', color);
167 // Bind a function to the unhighlight event to clean up after highlighting.
168 $('#chart1b').bind('jqplotDataUnhighlight',
169 function (ev, seriesIndex, pointIndex, data) {
170 $('#tooltip1b').empty();
171 $('#tooltip1b').hide();
172 $('#legend1b tr').css('background-color', '#ffffff');
174 });</script>
176 <script class="code" language="javascript" type="text/javascript">$(document).ready(function(){
178 var arr = [[11, 123, 1236, {label:"Acura", color:'sandybrown'}],
179 [45, 92, 1067, {label:"Alfa Romeo", color:'skyblue'}],
180 [24, 104, 1176, {label:"AM General", color:"salmon"}], [50, 23, 610, {color:"papayawhip"}],
181 [18, 17, 539, "Audi"], [7, 89, 864], [2, 13, 1026, "Bugatti"]];
183 plot1c = $.jqplot('chart1c',[arr],{
184 title: 'Bubble Data Customizations',
185 seriesDefaults:{
186 renderer: $.jqplot.BubbleRenderer
190 });</script>
192 <script class="code" language="javascript" type="text/javascript">$(document).ready(function(){
194 var arr = [[11, 123, 1236, "Acura"], [45, 92, 1067, "Alfa Romeo"],
195 [24, 104, 1176, "AM General"], [50, 23, 610, "Aston Martin Lagonda"],
196 [18, 17, 539, "Audi"], [7, 89, 864, "BMW"], [2, 13, 1026, "Bugatti"]];
198 plot2 = $.jqplot('chart2',[arr],{
199 title: 'Bubble Gradient Fills*',
200 seriesDefaults:{
201 renderer: $.jqplot.BubbleRenderer,
202 rendererOptions: {
203 bubbleGradients: true
205 shadow: true
209 });</script>
211 <script class="code" language="javascript" type="text/javascript">$(document).ready(function(){
213 var arr = [[44, 66, 897, "Acura"], [25, 40, 1119, "Alfa Romeo"], [2, 33, 1197, "AM General"],
214 [4, 132, 896, "Aston Martin Lagonda"], [2, 129, 314, "Audi"], [14, 47, 612, "BMW"],
215 [45, 112, 719, "Bugatti"], [11, 38, 785, "Buick"], [15, 39, 367, "Cadillac"],
216 [6, 133, 726, "Chevrolet"], [48, 84, 1082, "Citroen"], [40, 18, 1047, "DaimlerChrysler Corporation"],
217 [24, 107, 1065, "Daewoo Motor Co."], [27, 92, 792, "Delorean Motor Company"], [1, 78, 803, "Dodge"],
218 [5, 149, 320, "Ferrari"], [11, 127, 497, "Fiat"], [14, 18, 805, "Ford Motor Company"],
219 [9, 101, 394, "General Motors"], [16, 57, 338, "GMC"], [19, 89, 977, "Holden"],
220 [35, 78, 464, "Honda"], [18, 130, 364, "Hummer"], [37, 20, 699, "Hyundai"],
221 [33, 140, 457, "Infiniti"], [12, 122, 533, "Isuzu"], [25, 67, 767, "Jaguar Cars"],
222 [0, 7, 481, "Jeep"], [38, 36, 611, "Jensen Motors"], [43, 91, 943, "Kia"], [45, 21, 569, "Laforza"]];
224 plot3 = $.jqplot('chart3',[arr],{
225 title: 'Bubble Auto Scaling Options',
226 seriesDefaults:{
227 renderer: $.jqplot.BubbleRenderer,
228 rendererOptions: {
229 autoscalePointsFactor: -0.15,
230 autoscaleMultiplier: 0.85,
231 highlightMouseDown: true,
232 bubbleAlpha: 0.7
234 shadow: true,
235 shadowAlpha: 0.05
239 });</script>
242 <!-- End example scripts -->
244 <!-- Don't touch this! -->
247 <script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
248 <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
249 <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
250 <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
251 <!-- Additional plugins go here -->
253 <script class="include" type="text/javascript" src="../plugins/jqplot.bubbleRenderer.min.js"></script>
255 <!-- End additional plugins -->
258 </div>
259 <script type="text/javascript" src="example.min.js"></script>
261 </body>
264 </html>