bubble-plots.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Bubble Plots</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. .note {
  28. font-size: 0.8em;
  29. }
  30. #tooltip1b {
  31. font-size: 12px;
  32. color: rgb(15%, 15%, 15%);
  33. padding:2px;
  34. background-color: rgba(95%, 95%, 95%, 0.8);
  35. }
  36. #legend1b {
  37. font-size: 12px;
  38. border: 1px solid #cdcdcd;
  39. border-collapse: collapse;
  40. }
  41. #legend1b td, #legend1b th {
  42. border: 1px solid #cdcdcd;
  43. padding: 1px 4px;
  44. }
  45. </style>
  46. <p>Bubble charts represent 3 dimensional data. First, a basic bubble chart with the "bubbleGradients: true" option to specify gradient fills. Radial gradients are not supported in IE version before IE 9 and will be automatically disabled.</p>
  47. <div id="chart1" style="height:340px; width:460px;"></div>
  48. <pre class="code prettyprint brush: js"></pre>
  49. <p>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>Next are some basic customizations of bubble appearance with the "bubbleAlpha" and "highlightAlpha" options.</p>
  52. <div id="chart2" style="height:340px; width:460px;"></div>
  53. <pre class="code prettyprint brush: js"></pre>
  54. <p>In the following example, display of a custom toolip and highlighting of a custom table legend is performed by binding to the "jqplotDataHighlight" and "jqplotDataUnhighlight" events. The custom legend table here is dynamically created with a few lines of jQuery (O.K., it could be done in one line) based on the data array of the plot.</p>
  55. <div style="position:absolute;z-index:99;display:none;" id="tooltip1b"></div>
  56. <table style="margin-left:auto; margin-right:auto;"><tr>
  57. <td><div id="chart1b" style="width:460px;height:340px;"></div></td>
  58. <td><div style="height:340px;"><table id="legend1b"><tr><th>Company</th><th>R Value</th></tr></table></div></td>
  59. </tr></table>
  60. <pre class="code prettyprint brush: js"></pre>
  61. <script class="code" type="text/javascript">
  62. $(document).ready(function(){
  63. var arr = [[11, 123, 1236, "Acura"], [45, 92, 1067, "Alfa Romeo"],
  64. [24, 104, 1176, "AM General"], [50, 23, 610, "Aston Martin Lagonda"],
  65. [18, 17, 539, "Audi"], [7, 89, 864, "BMW"], [2, 13, 1026, "Bugatti"]];
  66. var plot1 = $.jqplot('chart1',[arr],{
  67. title: 'Bubble Chart with Gradient Fills',
  68. seriesDefaults:{
  69. renderer: $.jqplot.BubbleRenderer,
  70. rendererOptions: {
  71. bubbleGradients: true
  72. },
  73. shadow: true
  74. }
  75. });
  76. });
  77. </script>
  78. <script class="code" type="text/javascript">
  79. $(document).ready(function(){
  80. var arr = [[11, 123, 1236, "Acura"], [45, 92, 1067, "Alfa Romeo"],
  81. [24, 104, 1176, "AM General"], [50, 23, 610, "Aston Martin Lagonda"],
  82. [18, 17, 539, "Audi"], [7, 89, 864, "BMW"], [2, 13, 1026, "Bugatti"]];
  83. var plot2 = $.jqplot('chart2',[arr],{
  84. title: 'Transparent Bubbles',
  85. seriesDefaults:{
  86. renderer: $.jqplot.BubbleRenderer,
  87. rendererOptions: {
  88. bubbleAlpha: 0.6,
  89. highlightAlpha: 0.8
  90. },
  91. shadow: true,
  92. shadowAlpha: 0.05
  93. }
  94. });
  95. });
  96. </script>
  97. <script class="code" type="text/javascript">
  98. $(document).ready(function(){
  99. var arr = [[11, 123, 1236, "Acura"], [45, 92, 1067, "Alfa Romeo"],
  100. [24, 104, 1176, "AM General"], [50, 23, 610, "Aston Martin Lagonda"],
  101. [18, 17, 539, "Audi"], [7, 89, 864, "BMW"], [2, 13, 1026, "Bugatti"]];
  102. var plot1b = $.jqplot('chart1b',[arr],{
  103. title: 'Tooltip and Custom Legend Highlighting',
  104. seriesDefaults:{
  105. renderer: $.jqplot.BubbleRenderer,
  106. rendererOptions: {
  107. bubbleAlpha: 0.6,
  108. highlightAlpha: 0.8,
  109. showLabels: false
  110. },
  111. shadow: true,
  112. shadowAlpha: 0.05
  113. }
  114. });
  115. // Legend is a simple table in the html.
  116. // Dynamically populate it with the labels from each data value.
  117. $.each(arr, function(index, val) {
  118. $('#legend1b').append('<tr><td>'+val[3]+'</td><td>'+val[2]+'</td></tr>');
  119. });
  120. // Now bind function to the highlight event to show the tooltip
  121. // and highlight the row in the legend.
  122. $('#chart1b').bind('jqplotDataHighlight',
  123. function (ev, seriesIndex, pointIndex, data, radius) {
  124. var chart_left = $('#chart1b').offset().left,
  125. chart_top = $('#chart1b').offset().top,
  126. x = plot1b.axes.xaxis.u2p(data[0]), // convert x axis unita to pixels
  127. y = plot1b.axes.yaxis.u2p(data[1]); // convert y axis units to pixels
  128. var color = 'rgb(50%,50%,100%)';
  129. $('#tooltip1b').css({left:chart_left+x+radius+5, top:chart_top+y});
  130. $('#tooltip1b').html('<span style="font-size:14px;font-weight:bold;color:' +
  131. color + ';">' + data[3] + '</span><br />' + 'x: ' + data[0] +
  132. '<br />' + 'y: ' + data[1] + '<br />' + 'r: ' + data[2]);
  133. $('#tooltip1b').show();
  134. $('#legend1b tr').css('background-color', '#ffffff');
  135. $('#legend1b tr').eq(pointIndex+1).css('background-color', color);
  136. });
  137. // Bind a function to the unhighlight event to clean up after highlighting.
  138. $('#chart1b').bind('jqplotDataUnhighlight',
  139. function (ev, seriesIndex, pointIndex, data) {
  140. $('#tooltip1b').empty();
  141. $('#tooltip1b').hide();
  142. $('#legend1b tr').css('background-color', '#ffffff');
  143. });
  144. });
  145. </script>
  146. <!-- End example scripts -->
  147. <!-- Don't touch this! -->
  148. <script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
  149. <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
  150. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
  151. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
  152. <!-- End Don't touch this! -->
  153. <!-- Additional plugins go here -->
  154. <script class="include" language="javascript" type="text/javascript" src="../plugins/jqplot.bubbleRenderer.min.js"></script>
  155. <!-- End additional plugins -->
  156. </div>
  157. <div class="col2">
  158. <div class="example-link"><a class="example-link" href="data-renderers.html">AJAX and JSON Data Loading via Data Renderers</a></div>
  159. <div class="example-link"><a class="example-link" href="barLineAnimated.html">Animated Charts</a></div>
  160. <div class="example-link"><a class="example-link" href="dashboardWidget.html">Animated Dashboard Sample - Filled Line with Log Axis</a></div>
  161. <div class="example-link"><a class="example-link" href="kcp_area.html">Area Chart</a></div>
  162. <div class="example-link"><a class="example-link" href="kcp_area2.html">Area Chart 2</a></div>
  163. <div class="example-link"><a class="example-link" href="axisLabelTests.html">Axis Labels</a></div>
  164. <div class="example-link"><a class="example-link" href="axisLabelsRotatedText.html">Axis Labels and Rotated Text</a></div>
  165. <div class="example-link"><a class="example-link" href="barTest.html">Bar Charts</a></div>
  166. <div class="example-link"><a class="example-link" href="multipleBarColors.html">Bar Colors Example</a></div>
  167. <div class="example-link"><a class="example-link" href="bezierCurve.html">Bezier Curve Plots</a></div>
  168. <div class="example-link"><a class="example-link" href="blockPlot.html">Block Plots</a></div>
  169. <div class="example-link"><a class="example-link" href="bubbleChart.html">Bubble Charts</a></div>
  170. <div class="example-link"><a class="example-link" href="bubble-plots.html">Bubble Plots</a></div>
  171. <div class="example-link"><a class="example-link" href="candlestick.html">Candlestick and Open Hi Low Close Charts</a></div>
  172. <div class="example-link"><a class="example-link" href="theming.html">Chart Theming</a></div>
  173. <div class="example-link"><a class="example-link" href="fillBetweenLines.html">Charts with Fill Between Lines</a></div>
  174. <div class="example-link"><a class="example-link" href="kcp_cdf.html">Cumulative Density Function Chart</a></div>
  175. <div class="example-link"><a class="example-link" href="dashedLines.html">Dashed Lines with Smoothing</a></div>
  176. <div class="example-link"><a class="example-link" href="cursor-highlighter.html">Data Point Highlighting, Tooltips and Cursor Tracking</a></div>
  177. <div class="example-link"><a class="example-link" href="point-labels.html">Data Point labels</a></div>
  178. <div class="example-link"><a class="example-link" href="date-axes.html">Date Axes</a></div>
  179. <div class="example-link"><a class="example-link" href="dateAxisRenderer.html">Date Axes 2</a></div>
  180. <div class="example-link"><a class="example-link" href="rotatedTickLabelsZoom.html">Date Axes, Rotated Labels and Zooming</a></div>
  181. <div class="example-link"><a class="example-link" href="canvas-overlay.html">Draw Lines on Plots - Canvas Overlay</a></div>
  182. <div class="example-link"><a class="example-link" href="draw-rectangles.html">Draw Rectangles on Plots</a></div>
  183. <div class="example-link"><a class="example-link" href="kcp_engel.html">Engel Curves</a></div>
  184. <div class="example-link"><a class="example-link" href="bandedLine.html">Error Bands and Confidence Intervals</a></div>
  185. <div class="example-link"><a class="example-link" href="area.html">Filled (Area) Charts</a></div>
  186. <div class="example-link"><a class="example-link" href="axisScalingForceTickAt.html">Force Plot to Have Tick at 0 or 100</a></div>
  187. <div class="example-link"><a class="example-link" href="hiddenPlotsInTabs.html">Hidden Plots</a></div>
  188. <div class="example-link"><a class="example-link" href="customHighlighterCursorTrendline.html">Highlighting, Dragging Points, Cursor and Trend Lines</a></div>
  189. <div class="example-link"><a class="example-link" href="line-charts.html">Line Charts and Options</a></div>
  190. <div class="example-link"><a class="example-link" href="kcp_lorenz.html">Lorenz Curves</a></div>
  191. <div class="example-link"><a class="example-link" href="mekkoCharts.html">Mekko Charts</a></div>
  192. <div class="example-link"><a class="example-link" href="meterGauge.html">Meter Gauge</a></div>
  193. <div class="example-link"><a class="example-link" href="candlestick-charts.html">Open Hi Low Close and Candlestick Charts</a></div>
  194. <div class="example-link"><a class="example-link" href="pieTest.html">Pie Charts and Options</a></div>
  195. <div class="example-link"><a class="example-link" href="pieTest4.html">Pie Charts and Options 2</a></div>
  196. <div class="example-link"><a class="example-link" href="pie-donut-charts.html">Pie and Donut Charts</a></div>
  197. <div class="example-link"><a class="example-link" href="selectorSyntax.html">Plot Creation with jQuery Selectors</a></div>
  198. <div class="example-link"><a class="example-link" href="zooming.html">Plot Zooming and Cursor Control</a></div>
  199. <div class="example-link"><a class="example-link" href="kcp_pdf.html">Probability Density Function Chart</a></div>
  200. <div class="example-link"><a class="example-link" href="kcp_pyramid_by_age.html">Pyramid Chart By Age</a></div>
  201. <div class="example-link"><a class="example-link" href="kcp_pyramid.html">Pyramid Charts</a></div>
  202. <div class="example-link"><a class="example-link" href="kcp_pyramid2.html">Pyramid Charts 2</a></div>
  203. <div class="example-link"><a class="example-link" href="kcp_quintiles.html">Quintile Pyramid Charts</a></div>
  204. <div class="example-link"><a class="example-link" href="resizablePlot.html">Resizable Plots</a></div>
  205. <div class="example-link"><a class="example-link" href="rotated-tick-labels.html">Rotated Labels and Font Styling</a></div>
  206. <div class="example-link"><a class="example-link" href="smoothedLine.html">Smoothed Lines</a></div>
  207. <div class="example-link"><a class="example-link" href="bar-charts.html">Vertical and Horizontal Bar Charts</a></div>
  208. <div class="example-link"><a class="example-link" href="waterfall.html">Waterfall Charts</a></div>
  209. <div class="example-link"><a class="example-link" href="waterfall2.html">Waterfall Charts 2</a></div>
  210. <div class="example-link"><a class="example-link" href="zoomOptions.html">Zoom Options</a></div>
  211. <div class="example-link"><a class="example-link" href="zoomProxy.html">Zoom Proxy - Control one plot from another</a></div>
  212. <div class="example-link"><a class="example-link" href="zoom1.html">Zooming</a></div>
  213. <div class="example-link"><a class="example-link" href="dateAxisLogAxisZooming.html">Zooming with Date and Log Axes</a></div>
  214. </div>
  215. </div>
  216. </div>
  217. <script type="text/javascript" src="example.min.js"></script>
  218. </body>
  219. </html>