bubbleChart.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Bubble Charts</title>
  5. <link class="include" rel="stylesheet" type="text/css" href="../jquery.jqplot.min.css" />
  6. <link rel="stylesheet" type="text/css" href="examples.min.css" />
  7. <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCoreDefault.min.css" />
  8. <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemejqPlot.min.css" />
  9. <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
  10. <script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  11. </head>
  12. <body>
  13. <div id="header">
  14. <div class="nav">
  15. <a class="nav" href="../../../index.php"><span>&gt;</span>Home</a>
  16. <a class="nav" href="../../../docs/"><span>&gt;</span>Docs</a>
  17. <a class="nav" href="../../download/"><span>&gt;</span>Download</a>
  18. <a class="nav" href="../../../info.php"><span>&gt;</span>Info</a>
  19. <a class="nav" href="../../../donate.php"><span>&gt;</span>Donate</a>
  20. </div>
  21. </div>
  22. <div class="colmask leftmenu">
  23. <div class="colleft">
  24. <div class="col1" id="example-content">
  25. <!-- Example scripts go here -->
  26. <style type="text/css">
  27. .jqplot-target {
  28. margin-bottom: 2em;
  29. }
  30. .note {
  31. font-size: 0.8em;
  32. }
  33. #tooltip1b {
  34. font-size: 12px;
  35. color: rgb(15%, 15%, 15%);
  36. padding:2px;
  37. background-color: rgba(95%, 95%, 95%, 0.8);
  38. }
  39. #legend1b {
  40. font-size: 12px;
  41. border: 1px solid #cdcdcd;
  42. border-collapse: collapse;
  43. }
  44. #legend1b td, #legend1b th {
  45. border: 1px solid #cdcdcd;
  46. padding: 1px 4px;
  47. }
  48. </style>
  49. <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>
  50. <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>
  51. <p>The below chart show basic customization of bubble appearance with the "bubbleAlpha" and "highlightAlpha" options.</p>
  52. <div id="chart1" class="plot" style="width:460px;height:340px;"></div>
  53. <pre class="code brush:js"></pre>
  54. <div style="position:absolute;z-index:99;display:none;" id="tooltip1b"></div>
  55. <table><tr>
  56. <td><div id="chart1b" class="plot" style="width:460px;height:340px;"></div></td>
  57. <td><div style="height:340px;"><table id="legend1b"><tr><th>Company</th><th>R Value</th></tr></table></div></td>
  58. </tr></table>
  59. <pre class="code brush:js"></pre>
  60. <p>Below is a basic bubble chart showing usage of the optional label and color properties passed in with the data.</p>
  61. <div id="chart1c" class="plot" style="width:460px;height:340px;"></div>
  62. <pre class="code brush:js"></pre>
  63. <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>
  64. <div id="chart2" class="plot" style="width:460px;height:340px;"></div>
  65. <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>
  66. <pre class="code brush:js"></pre>
  67. <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>
  68. <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>
  69. <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>
  70. <div id="chart3" class="plot" style="width:600px;height:400px;"></div>
  71. <pre class="code brush:js"></pre>
  72. <script class="code" language="javascript" type="text/javascript">$(document).ready(function(){
  73. var arr = [[11, 123, 1236, "Acura"], [45, 92, 1067, "Alfa Romeo"],
  74. [24, 104, 1176, "AM General"], [50, 23, 610, "Aston Martin Lagonda"],
  75. [18, 17, 539, "Audi"], [7, 89, 864, "BMW"], [2, 13, 1026, "Bugatti"]];
  76. plot1 = $.jqplot('chart1',[arr],{
  77. title: 'Transparent Bubbles',
  78. seriesDefaults:{
  79. renderer: $.jqplot.BubbleRenderer,
  80. rendererOptions: {
  81. bubbleAlpha: 0.6,
  82. highlightAlpha: 0.8
  83. },
  84. shadow: true,
  85. shadowAlpha: 0.05
  86. }
  87. });
  88. });</script>
  89. <script class="code" language="javascript" type="text/javascript">$(document).ready(function(){
  90. var arr = [[11, 123, 1236, "Acura"], [45, 92, 1067, "Alfa Romeo"],
  91. [24, 104, 1176, "AM General"], [50, 23, 610, "Aston Martin Lagonda"],
  92. [18, 17, 539, "Audi"], [7, 89, 864, "BMW"], [2, 13, 1026, "Bugatti"]];
  93. plot1b = $.jqplot('chart1b',[arr],{
  94. title: 'Tooltip and Custom Legend Highlighting',
  95. seriesDefaults:{
  96. renderer: $.jqplot.BubbleRenderer,
  97. rendererOptions: {
  98. bubbleAlpha: 0.6,
  99. highlightAlpha: 0.8,
  100. showLabels: false
  101. },
  102. shadow: true,
  103. shadowAlpha: 0.05
  104. }
  105. });
  106. // Legend is a simple table in the html.
  107. // Now populate it with the labels from each data value.
  108. $.each(arr, function(index, val) {
  109. $('#legend1b').append('<tr><td>'+val[3]+'</td><td>'+val[2]+'</td></tr>');
  110. });
  111. // Now bind function to the highlight event to show the tooltip
  112. // and highlight the row in the legend.
  113. $('#chart1b').bind('jqplotDataHighlight',
  114. function (ev, seriesIndex, pointIndex, data, radius) {
  115. var chart_left = $('#chart1b').offset().left,
  116. chart_top = $('#chart1b').offset().top,
  117. x = plot1b.axes.xaxis.u2p(data[0]), // convert x axis unita to pixels on grid
  118. y = plot1b.axes.yaxis.u2p(data[1]); // convert y axis units to pixels on grid
  119. var color = 'rgb(50%,50%,100%)';
  120. $('#tooltip1b').css({left:chart_left+x+radius+5, top:chart_top+y});
  121. $('#tooltip1b').html('<span style="font-size:14px;font-weight:bold;color:'+color+';">' +
  122. data[3] + '</span><br />' + 'x: '+data[0] + '<br />' + 'y: ' +
  123. data[1] + '<br />' + 'r: ' + data[2]);
  124. $('#tooltip1b').show();
  125. $('#legend1b tr').css('background-color', '#ffffff');
  126. $('#legend1b tr').eq(pointIndex+1).css('background-color', color);
  127. });
  128. // Bind a function to the unhighlight event to clean up after highlighting.
  129. $('#chart1b').bind('jqplotDataUnhighlight',
  130. function (ev, seriesIndex, pointIndex, data) {
  131. $('#tooltip1b').empty();
  132. $('#tooltip1b').hide();
  133. $('#legend1b tr').css('background-color', '#ffffff');
  134. });
  135. });</script>
  136. <script class="code" language="javascript" type="text/javascript">$(document).ready(function(){
  137. var arr = [[11, 123, 1236, {label:"Acura", color:'sandybrown'}],
  138. [45, 92, 1067, {label:"Alfa Romeo", color:'skyblue'}],
  139. [24, 104, 1176, {label:"AM General", color:"salmon"}], [50, 23, 610, {color:"papayawhip"}],
  140. [18, 17, 539, "Audi"], [7, 89, 864], [2, 13, 1026, "Bugatti"]];
  141. plot1c = $.jqplot('chart1c',[arr],{
  142. title: 'Bubble Data Customizations',
  143. seriesDefaults:{
  144. renderer: $.jqplot.BubbleRenderer
  145. }
  146. });
  147. });</script>
  148. <script class="code" language="javascript" type="text/javascript">$(document).ready(function(){
  149. var arr = [[11, 123, 1236, "Acura"], [45, 92, 1067, "Alfa Romeo"],
  150. [24, 104, 1176, "AM General"], [50, 23, 610, "Aston Martin Lagonda"],
  151. [18, 17, 539, "Audi"], [7, 89, 864, "BMW"], [2, 13, 1026, "Bugatti"]];
  152. plot2 = $.jqplot('chart2',[arr],{
  153. title: 'Bubble Gradient Fills*',
  154. seriesDefaults:{
  155. renderer: $.jqplot.BubbleRenderer,
  156. rendererOptions: {
  157. bubbleGradients: true
  158. },
  159. shadow: true
  160. }
  161. });
  162. });</script>
  163. <script class="code" language="javascript" type="text/javascript">$(document).ready(function(){
  164. var arr = [[44, 66, 897, "Acura"], [25, 40, 1119, "Alfa Romeo"], [2, 33, 1197, "AM General"],
  165. [4, 132, 896, "Aston Martin Lagonda"], [2, 129, 314, "Audi"], [14, 47, 612, "BMW"],
  166. [45, 112, 719, "Bugatti"], [11, 38, 785, "Buick"], [15, 39, 367, "Cadillac"],
  167. [6, 133, 726, "Chevrolet"], [48, 84, 1082, "Citroen"], [40, 18, 1047, "DaimlerChrysler Corporation"],
  168. [24, 107, 1065, "Daewoo Motor Co."], [27, 92, 792, "Delorean Motor Company"], [1, 78, 803, "Dodge"],
  169. [5, 149, 320, "Ferrari"], [11, 127, 497, "Fiat"], [14, 18, 805, "Ford Motor Company"],
  170. [9, 101, 394, "General Motors"], [16, 57, 338, "GMC"], [19, 89, 977, "Holden"],
  171. [35, 78, 464, "Honda"], [18, 130, 364, "Hummer"], [37, 20, 699, "Hyundai"],
  172. [33, 140, 457, "Infiniti"], [12, 122, 533, "Isuzu"], [25, 67, 767, "Jaguar Cars"],
  173. [0, 7, 481, "Jeep"], [38, 36, 611, "Jensen Motors"], [43, 91, 943, "Kia"], [45, 21, 569, "Laforza"]];
  174. plot3 = $.jqplot('chart3',[arr],{
  175. title: 'Bubble Auto Scaling Options',
  176. seriesDefaults:{
  177. renderer: $.jqplot.BubbleRenderer,
  178. rendererOptions: {
  179. autoscalePointsFactor: -0.15,
  180. autoscaleMultiplier: 0.85,
  181. highlightMouseDown: true,
  182. bubbleAlpha: 0.7
  183. },
  184. shadow: true,
  185. shadowAlpha: 0.05
  186. }
  187. });
  188. });</script>
  189. <!-- End example scripts -->
  190. <!-- Don't touch this! -->
  191. <script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
  192. <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
  193. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
  194. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
  195. <!-- Additional plugins go here -->
  196. <script class="include" type="text/javascript" src="../plugins/jqplot.bubbleRenderer.min.js"></script>
  197. <!-- End additional plugins -->
  198. </div>
  199. <div class="col2">
  200. <div class="example-link"><a class="example-link" href="data-renderers.html">AJAX and JSON Data Loading via Data Renderers</a></div>
  201. <div class="example-link"><a class="example-link" href="barLineAnimated.html">Animated Charts</a></div>
  202. <div class="example-link"><a class="example-link" href="dashboardWidget.html">Animated Dashboard Sample - Filled Line with Log Axis</a></div>
  203. <div class="example-link"><a class="example-link" href="kcp_area.html">Area Chart</a></div>
  204. <div class="example-link"><a class="example-link" href="kcp_area2.html">Area Chart 2</a></div>
  205. <div class="example-link"><a class="example-link" href="axisLabelTests.html">Axis Labels</a></div>
  206. <div class="example-link"><a class="example-link" href="axisLabelsRotatedText.html">Axis Labels and Rotated Text</a></div>
  207. <div class="example-link"><a class="example-link" href="barTest.html">Bar Charts</a></div>
  208. <div class="example-link"><a class="example-link" href="multipleBarColors.html">Bar Colors Example</a></div>
  209. <div class="example-link"><a class="example-link" href="bezierCurve.html">Bezier Curve Plots</a></div>
  210. <div class="example-link"><a class="example-link" href="blockPlot.html">Block Plots</a></div>
  211. <div class="example-link"><a class="example-link" href="bubbleChart.html">Bubble Charts</a></div>
  212. <div class="example-link"><a class="example-link" href="bubble-plots.html">Bubble Plots</a></div>
  213. <div class="example-link"><a class="example-link" href="candlestick.html">Candlestick and Open Hi Low Close Charts</a></div>
  214. <div class="example-link"><a class="example-link" href="theming.html">Chart Theming</a></div>
  215. <div class="example-link"><a class="example-link" href="fillBetweenLines.html">Charts with Fill Between Lines</a></div>
  216. <div class="example-link"><a class="example-link" href="kcp_cdf.html">Cumulative Density Function Chart</a></div>
  217. <div class="example-link"><a class="example-link" href="dashedLines.html">Dashed Lines with Smoothing</a></div>
  218. <div class="example-link"><a class="example-link" href="cursor-highlighter.html">Data Point Highlighting, Tooltips and Cursor Tracking</a></div>
  219. <div class="example-link"><a class="example-link" href="point-labels.html">Data Point labels</a></div>
  220. <div class="example-link"><a class="example-link" href="date-axes.html">Date Axes</a></div>
  221. <div class="example-link"><a class="example-link" href="dateAxisRenderer.html">Date Axes 2</a></div>
  222. <div class="example-link"><a class="example-link" href="rotatedTickLabelsZoom.html">Date Axes, Rotated Labels and Zooming</a></div>
  223. <div class="example-link"><a class="example-link" href="canvas-overlay.html">Draw Lines on Plots - Canvas Overlay</a></div>
  224. <div class="example-link"><a class="example-link" href="draw-rectangles.html">Draw Rectangles on Plots</a></div>
  225. <div class="example-link"><a class="example-link" href="kcp_engel.html">Engel Curves</a></div>
  226. <div class="example-link"><a class="example-link" href="bandedLine.html">Error Bands and Confidence Intervals</a></div>
  227. <div class="example-link"><a class="example-link" href="area.html">Filled (Area) Charts</a></div>
  228. <div class="example-link"><a class="example-link" href="axisScalingForceTickAt.html">Force Plot to Have Tick at 0 or 100</a></div>
  229. <div class="example-link"><a class="example-link" href="hiddenPlotsInTabs.html">Hidden Plots</a></div>
  230. <div class="example-link"><a class="example-link" href="customHighlighterCursorTrendline.html">Highlighting, Dragging Points, Cursor and Trend Lines</a></div>
  231. <div class="example-link"><a class="example-link" href="line-charts.html">Line Charts and Options</a></div>
  232. <div class="example-link"><a class="example-link" href="kcp_lorenz.html">Lorenz Curves</a></div>
  233. <div class="example-link"><a class="example-link" href="mekkoCharts.html">Mekko Charts</a></div>
  234. <div class="example-link"><a class="example-link" href="meterGauge.html">Meter Gauge</a></div>
  235. <div class="example-link"><a class="example-link" href="candlestick-charts.html">Open Hi Low Close and Candlestick Charts</a></div>
  236. <div class="example-link"><a class="example-link" href="pieTest.html">Pie Charts and Options</a></div>
  237. <div class="example-link"><a class="example-link" href="pieTest4.html">Pie Charts and Options 2</a></div>
  238. <div class="example-link"><a class="example-link" href="pie-donut-charts.html">Pie and Donut Charts</a></div>
  239. <div class="example-link"><a class="example-link" href="selectorSyntax.html">Plot Creation with jQuery Selectors</a></div>
  240. <div class="example-link"><a class="example-link" href="zooming.html">Plot Zooming and Cursor Control</a></div>
  241. <div class="example-link"><a class="example-link" href="kcp_pdf.html">Probability Density Function Chart</a></div>
  242. <div class="example-link"><a class="example-link" href="kcp_pyramid_by_age.html">Pyramid Chart By Age</a></div>
  243. <div class="example-link"><a class="example-link" href="kcp_pyramid.html">Pyramid Charts</a></div>
  244. <div class="example-link"><a class="example-link" href="kcp_pyramid2.html">Pyramid Charts 2</a></div>
  245. <div class="example-link"><a class="example-link" href="kcp_quintiles.html">Quintile Pyramid Charts</a></div>
  246. <div class="example-link"><a class="example-link" href="resizablePlot.html">Resizable Plots</a></div>
  247. <div class="example-link"><a class="example-link" href="rotated-tick-labels.html">Rotated Labels and Font Styling</a></div>
  248. <div class="example-link"><a class="example-link" href="smoothedLine.html">Smoothed Lines</a></div>
  249. <div class="example-link"><a class="example-link" href="bar-charts.html">Vertical and Horizontal Bar Charts</a></div>
  250. <div class="example-link"><a class="example-link" href="waterfall.html">Waterfall Charts</a></div>
  251. <div class="example-link"><a class="example-link" href="waterfall2.html">Waterfall Charts 2</a></div>
  252. <div class="example-link"><a class="example-link" href="zoomOptions.html">Zoom Options</a></div>
  253. <div class="example-link"><a class="example-link" href="zoomProxy.html">Zoom Proxy - Control one plot from another</a></div>
  254. <div class="example-link"><a class="example-link" href="zoom1.html">Zooming</a></div>
  255. <div class="example-link"><a class="example-link" href="dateAxisLogAxisZooming.html">Zooming with Date and Log Axes</a></div>
  256. </div>
  257. </div>
  258. </div>
  259. <script type="text/javascript" src="example.min.js"></script>
  260. </body>
  261. </html>