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.

137 lines
3.5 KiB

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