index.htm 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. </style>
  9. </head>
  10. <body>
  11. <script src="../../code/highcharts.js"></script>
  12. <script src="../../code/highcharts-more.js"></script>
  13. <script src="../../code/modules/exporting.js"></script>
  14. <script src="../../code/modules/export-data.js"></script>
  15. <div id="container" style="min-width: 310px; max-width: 400px; height: 300px; margin: 0 auto"></div>
  16. <script type="text/javascript">
  17. Highcharts.chart('container', {
  18. chart: {
  19. type: 'gauge',
  20. plotBackgroundColor: null,
  21. plotBackgroundImage: null,
  22. plotBorderWidth: 0,
  23. plotShadow: false
  24. },
  25. title: {
  26. text: 'Speedometer'
  27. },
  28. pane: {
  29. startAngle: -150,
  30. endAngle: 150,
  31. background: [{
  32. backgroundColor: {
  33. linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
  34. stops: [
  35. [0, '#FFF'],
  36. [1, '#333']
  37. ]
  38. },
  39. borderWidth: 0,
  40. outerRadius: '109%'
  41. }, {
  42. backgroundColor: {
  43. linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
  44. stops: [
  45. [0, '#333'],
  46. [1, '#FFF']
  47. ]
  48. },
  49. borderWidth: 1,
  50. outerRadius: '107%'
  51. }, {
  52. // default background
  53. }, {
  54. backgroundColor: '#DDD',
  55. borderWidth: 0,
  56. outerRadius: '105%',
  57. innerRadius: '103%'
  58. }]
  59. },
  60. // the value axis
  61. yAxis: {
  62. min: 0,
  63. max: 200,
  64. minorTickInterval: 'auto',
  65. minorTickWidth: 1,
  66. minorTickLength: 10,
  67. minorTickPosition: 'inside',
  68. minorTickColor: '#666',
  69. tickPixelInterval: 30,
  70. tickWidth: 2,
  71. tickPosition: 'inside',
  72. tickLength: 10,
  73. tickColor: '#666',
  74. labels: {
  75. step: 2,
  76. rotation: 'auto'
  77. },
  78. title: {
  79. text: 'km/h'
  80. },
  81. plotBands: [{
  82. from: 0,
  83. to: 120,
  84. color: '#55BF3B' // green
  85. }, {
  86. from: 120,
  87. to: 160,
  88. color: '#DDDF0D' // yellow
  89. }, {
  90. from: 160,
  91. to: 200,
  92. color: '#DF5353' // red
  93. }]
  94. },
  95. series: [{
  96. name: 'Speed',
  97. data: [80],
  98. tooltip: {
  99. valueSuffix: ' km/h'
  100. }
  101. }]
  102. },
  103. // Add some life
  104. function (chart) {
  105. if (!chart.renderer.forExport) {
  106. setInterval(function () {
  107. var point = chart.series[0].points[0],
  108. newVal,
  109. inc = Math.round((Math.random() - 0.5) * 20);
  110. newVal = point.y + inc;
  111. if (newVal < 0 || newVal > 200) {
  112. newVal = point.y - inc;
  113. }
  114. point.update(newVal);
  115. }, 3000);
  116. }
  117. });
  118. </script>
  119. </body>
  120. </html>