You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
4.5 KiB

9 years ago
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Highcharts Example</title>
  6. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  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. <script type="text/javascript">
  16. $(function () {
  17. // Give the points a 3D feel by adding a radial gradient
  18. Highcharts.getOptions().colors = $.map(Highcharts.getOptions().colors, function (color) {
  19. return {
  20. radialGradient: {
  21. cx: 0.4,
  22. cy: 0.3,
  23. r: 0.5
  24. },
  25. stops: [
  26. [0, color],
  27. [1, Highcharts.Color(color).brighten(-0.2).get('rgb')]
  28. ]
  29. };
  30. });
  31. // Set up the chart
  32. var chart = new Highcharts.Chart({
  33. chart: {
  34. renderTo: 'container',
  35. margin: 100,
  36. type: 'scatter',
  37. options3d: {
  38. enabled: true,
  39. alpha: 10,
  40. beta: 30,
  41. depth: 250,
  42. viewDistance: 5,
  43. frame: {
  44. bottom: { size: 1, color: 'rgba(0,0,0,0.02)' },
  45. back: { size: 1, color: 'rgba(0,0,0,0.04)' },
  46. side: { size: 1, color: 'rgba(0,0,0,0.06)' }
  47. }
  48. }
  49. },
  50. title: {
  51. text: 'Draggable box'
  52. },
  53. subtitle: {
  54. text: 'Click and drag the plot area to rotate in space'
  55. },
  56. plotOptions: {
  57. scatter: {
  58. width: 10,
  59. height: 10,
  60. depth: 10
  61. }
  62. },
  63. yAxis: {
  64. min: 0,
  65. max: 10,
  66. title: null
  67. },
  68. xAxis: {
  69. min: 0,
  70. max: 10,
  71. gridLineWidth: 1
  72. },
  73. zAxis: {
  74. min: 0,
  75. max: 10,
  76. showFirstLabel: false
  77. },
  78. legend: {
  79. enabled: false
  80. },
  81. series: [{
  82. name: 'Reading',
  83. colorByPoint: true,
  84. data: [[1, 6, 5], [8, 7, 9], [1, 3, 4], [4, 6, 8], [5, 7, 7], [6, 9, 6], [7, 0, 5], [2, 3, 3], [3, 9, 8], [3, 6, 5], [4, 9, 4], [2, 3, 3], [6, 9, 9], [0, 7, 0], [7, 7, 9], [7, 2, 9], [0, 6, 2], [4, 6, 7], [3, 7, 7], [0, 1, 7], [2, 8, 6], [2, 3, 7], [6, 4, 8], [3, 5, 9], [7, 9, 5], [3, 1, 7], [4, 4, 2], [3, 6, 2], [3, 1, 6], [6, 8, 5], [6, 6, 7], [4, 1, 1], [7, 2, 7], [7, 7, 0], [8, 8, 9], [9, 4, 1], [8, 3, 4], [9, 8, 9], [3, 5, 3], [0, 2, 4], [6, 0, 2], [2, 1, 3], [5, 8, 9], [2, 1, 1], [9, 7, 6], [3, 0, 2], [9, 9, 0], [3, 4, 8], [2, 6, 1], [8, 9, 2], [7, 6, 5], [6, 3, 1], [9, 3, 1], [8, 9, 3], [9, 1, 0], [3, 8, 7], [8, 0, 0], [4, 9, 7], [8, 6, 2], [4, 3, 0], [2, 3, 5], [9, 1, 4], [1, 1, 4], [6, 0, 2], [6, 1, 6], [3, 8, 8], [8, 8, 7], [5, 5, 0], [3, 9, 6], [5, 4, 3], [6, 8, 3], [0, 1, 5], [6, 7, 3], [8, 3, 2], [3, 8, 3], [2, 1, 6], [4, 6, 7], [8, 9, 9], [5, 4, 2], [6, 1, 3], [6, 9, 5], [4, 8, 2], [9, 7, 4], [5, 4, 2], [9, 6, 1], [2, 7, 3], [4, 5, 4], [6, 8, 1], [3, 4, 0], [2, 2, 6], [5, 1, 2], [9, 9, 7], [6, 9, 9], [8, 4, 3], [4, 1, 7], [6, 2, 5], [0, 4, 9], [3, 5, 9], [6, 9, 1], [1, 9, 2]]
  85. }]
  86. });
  87. // Add mouse events for rotation
  88. $(chart.container).bind('mousedown.hc touchstart.hc', function (e) {
  89. e = chart.pointer.normalize(e);
  90. var posX = e.pageX,
  91. posY = e.pageY,
  92. alpha = chart.options.chart.options3d.alpha,
  93. beta = chart.options.chart.options3d.beta,
  94. newAlpha,
  95. newBeta,
  96. sensitivity = 5; // lower is more sensitive
  97. $(document).bind({
  98. 'mousemove.hc touchdrag.hc': function (e) {
  99. // Run beta
  100. newBeta = beta + (posX - e.pageX) / sensitivity;
  101. chart.options.chart.options3d.beta = newBeta;
  102. // Run alpha
  103. newAlpha = alpha + (e.pageY - posY) / sensitivity;
  104. chart.options.chart.options3d.alpha = newAlpha;
  105. chart.redraw(false);
  106. },
  107. 'mouseup touchend': function () {
  108. $(document).unbind('.hc');
  109. }
  110. });
  111. });
  112. });
  113. </script>
  114. </head>
  115. <body>
  116. <script src="../../js/highcharts.js"></script>
  117. <script src="../../js/highcharts-3d.js"></script>
  118. <script src="../../js/modules/exporting.js"></script>
  119. <div id="container" style="height: 400px"></div>
  120. </body>
  121. </html>