index.htm 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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://cdn.hcharts.cn/jquery/jquery-1.8.3.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. fitToPlot: false,
  44. frame: {
  45. bottom: { size: 1, color: 'rgba(0,0,0,0.02)' },
  46. back: { size: 1, color: 'rgba(0,0,0,0.04)' },
  47. side: { size: 1, color: 'rgba(0,0,0,0.06)' }
  48. }
  49. }
  50. },
  51. title: {
  52. text: 'Draggable box'
  53. },
  54. subtitle: {
  55. text: 'Click and drag the plot area to rotate in space'
  56. },
  57. plotOptions: {
  58. scatter: {
  59. width: 10,
  60. height: 10,
  61. depth: 10
  62. }
  63. },
  64. yAxis: {
  65. min: 0,
  66. max: 10,
  67. title: null
  68. },
  69. xAxis: {
  70. min: 0,
  71. max: 10,
  72. gridLineWidth: 1
  73. },
  74. zAxis: {
  75. min: 0,
  76. max: 10,
  77. showFirstLabel: false
  78. },
  79. legend: {
  80. enabled: false
  81. },
  82. series: [{
  83. name: 'Reading',
  84. colorByPoint: true,
  85. 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]]
  86. }]
  87. });
  88. // Add mouse events for rotation
  89. $(chart.container).bind('mousedown.hc touchstart.hc', function (eStart) {
  90. eStart = chart.pointer.normalize(eStart);
  91. var posX = eStart.pageX,
  92. posY = eStart.pageY,
  93. alpha = chart.options.chart.options3d.alpha,
  94. beta = chart.options.chart.options3d.beta,
  95. newAlpha,
  96. newBeta,
  97. sensitivity = 5; // lower is more sensitive
  98. $(document).bind({
  99. 'mousemove.hc touchdrag.hc': function (e) {
  100. // Run beta
  101. newBeta = beta + (posX - e.pageX) / sensitivity;
  102. chart.options.chart.options3d.beta = newBeta;
  103. // Run alpha
  104. newAlpha = alpha + (e.pageY - posY) / sensitivity;
  105. chart.options.chart.options3d.alpha = newAlpha;
  106. chart.redraw(false);
  107. },
  108. 'mouseup touchend': function () {
  109. $(document).unbind('.hc');
  110. }
  111. });
  112. });
  113. });
  114. </script>
  115. </head>
  116. <body>
  117. <script src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
  118. <script src="http://cdn.hcharts.cn/highcharts/highcharts-3d.js"></script>
  119. <script src="http://cdn.hcharts.cn/highcharts/modules/exporting.js"></script>
  120. <div id="container" style="height: 400px"></div>
  121. </body>
  122. </html>