index.htm 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Highcharts Example</title>
  7. <style type="text/css">
  8. #container {
  9. height: 400px;
  10. min-width: 310px;
  11. max-width: 800px;
  12. margin: 0 auto;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <script src="../../code/highcharts.js"></script>
  18. <script src="../../code/highcharts-3d.js"></script>
  19. <script src="../../code/modules/exporting.js"></script>
  20. <script src="../../code/modules/export-data.js"></script>
  21. <div id="container" style="height: 500px"></div>
  22. <script type="text/javascript">
  23. // Give the points a 3D feel by adding a radial gradient
  24. Highcharts.setOptions({
  25. colors: Highcharts.getOptions().colors.map(function (color) {
  26. return {
  27. radialGradient: {
  28. cx: 0.4,
  29. cy: 0.3,
  30. r: 0.5
  31. },
  32. stops: [
  33. [0, color],
  34. [1, Highcharts.Color(color).brighten(-0.2).get('rgb')]
  35. ]
  36. };
  37. })
  38. });
  39. // Set up the chart
  40. var chart = new Highcharts.Chart({
  41. chart: {
  42. renderTo: 'container',
  43. margin: 100,
  44. type: 'scatter3d',
  45. animation: false,
  46. options3d: {
  47. enabled: true,
  48. alpha: 10,
  49. beta: 30,
  50. depth: 250,
  51. viewDistance: 5,
  52. fitToPlot: false,
  53. frame: {
  54. bottom: { size: 1, color: 'rgba(0,0,0,0.02)' },
  55. back: { size: 1, color: 'rgba(0,0,0,0.04)' },
  56. side: { size: 1, color: 'rgba(0,0,0,0.06)' }
  57. }
  58. }
  59. },
  60. title: {
  61. text: 'Draggable box'
  62. },
  63. subtitle: {
  64. text: 'Click and drag the plot area to rotate in space'
  65. },
  66. plotOptions: {
  67. scatter: {
  68. width: 10,
  69. height: 10,
  70. depth: 10
  71. }
  72. },
  73. yAxis: {
  74. min: 0,
  75. max: 10,
  76. title: null
  77. },
  78. xAxis: {
  79. min: 0,
  80. max: 10,
  81. gridLineWidth: 1
  82. },
  83. zAxis: {
  84. min: 0,
  85. max: 10,
  86. showFirstLabel: false
  87. },
  88. legend: {
  89. enabled: false
  90. },
  91. series: [{
  92. name: 'Reading',
  93. colorByPoint: true,
  94. data: [
  95. [1, 6, 5], [8, 7, 9], [1, 3, 4], [4, 6, 8], [5, 7, 7], [6, 9, 6],
  96. [7, 0, 5], [2, 3, 3], [3, 9, 8], [3, 6, 5], [4, 9, 4], [2, 3, 3],
  97. [6, 9, 9], [0, 7, 0], [7, 7, 9], [7, 2, 9], [0, 6, 2], [4, 6, 7],
  98. [3, 7, 7], [0, 1, 7], [2, 8, 6], [2, 3, 7], [6, 4, 8], [3, 5, 9],
  99. [7, 9, 5], [3, 1, 7], [4, 4, 2], [3, 6, 2], [3, 1, 6], [6, 8, 5],
  100. [6, 6, 7], [4, 1, 1], [7, 2, 7], [7, 7, 0], [8, 8, 9], [9, 4, 1],
  101. [8, 3, 4], [9, 8, 9], [3, 5, 3], [0, 2, 4], [6, 0, 2], [2, 1, 3],
  102. [5, 8, 9], [2, 1, 1], [9, 7, 6], [3, 0, 2], [9, 9, 0], [3, 4, 8],
  103. [2, 6, 1], [8, 9, 2], [7, 6, 5], [6, 3, 1], [9, 3, 1], [8, 9, 3],
  104. [9, 1, 0], [3, 8, 7], [8, 0, 0], [4, 9, 7], [8, 6, 2], [4, 3, 0],
  105. [2, 3, 5], [9, 1, 4], [1, 1, 4], [6, 0, 2], [6, 1, 6], [3, 8, 8],
  106. [8, 8, 7], [5, 5, 0], [3, 9, 6], [5, 4, 3], [6, 8, 3], [0, 1, 5],
  107. [6, 7, 3], [8, 3, 2], [3, 8, 3], [2, 1, 6], [4, 6, 7], [8, 9, 9],
  108. [5, 4, 2], [6, 1, 3], [6, 9, 5], [4, 8, 2], [9, 7, 4], [5, 4, 2],
  109. [9, 6, 1], [2, 7, 3], [4, 5, 4], [6, 8, 1], [3, 4, 0], [2, 2, 6],
  110. [5, 1, 2], [9, 9, 7], [6, 9, 9], [8, 4, 3], [4, 1, 7], [6, 2, 5],
  111. [0, 4, 9], [3, 5, 9], [6, 9, 1], [1, 9, 2]]
  112. }]
  113. });
  114. // Add mouse and touch events for rotation
  115. (function (H) {
  116. function dragStart(eStart) {
  117. eStart = chart.pointer.normalize(eStart);
  118. var posX = eStart.chartX,
  119. posY = eStart.chartY,
  120. alpha = chart.options.chart.options3d.alpha,
  121. beta = chart.options.chart.options3d.beta,
  122. sensitivity = 5, // lower is more sensitive
  123. handlers = [];
  124. function drag(e) {
  125. // Get e.chartX and e.chartY
  126. e = chart.pointer.normalize(e);
  127. chart.update({
  128. chart: {
  129. options3d: {
  130. alpha: alpha + (e.chartY - posY) / sensitivity,
  131. beta: beta + (posX - e.chartX) / sensitivity
  132. }
  133. }
  134. }, undefined, undefined, false);
  135. }
  136. function unbindAll() {
  137. handlers.forEach(function (unbind) {
  138. if (unbind) {
  139. unbind();
  140. }
  141. });
  142. handlers.length = 0;
  143. }
  144. handlers.push(H.addEvent(document, 'mousemove', drag));
  145. handlers.push(H.addEvent(document, 'touchmove', drag));
  146. handlers.push(H.addEvent(document, 'mouseup', unbindAll));
  147. handlers.push(H.addEvent(document, 'touchend', unbindAll));
  148. }
  149. H.addEvent(chart.container, 'mousedown', dragStart);
  150. H.addEvent(chart.container, 'touchstart', dragStart);
  151. }(Highcharts));
  152. </script>
  153. </body>
  154. </html>