市长热线演示版

index.htm 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. <script type="text/javascript">
  8. $(function () {
  9. var gaugeOptions = {
  10. chart: {
  11. type: 'solidgauge'
  12. },
  13. title: null,
  14. pane: {
  15. center: ['50%', '85%'],
  16. size: '140%',
  17. startAngle: -90,
  18. endAngle: 90,
  19. background: {
  20. backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
  21. innerRadius: '60%',
  22. outerRadius: '100%',
  23. shape: 'arc'
  24. }
  25. },
  26. tooltip: {
  27. enabled: false
  28. },
  29. // the value axis
  30. yAxis: {
  31. stops: [
  32. [0.1, '#55BF3B'], // green
  33. [0.5, '#DDDF0D'], // yellow
  34. [0.9, '#DF5353'] // red
  35. ],
  36. lineWidth: 0,
  37. minorTickInterval: null,
  38. tickPixelInterval: 400,
  39. tickWidth: 0,
  40. title: {
  41. y: -70
  42. },
  43. labels: {
  44. y: 16
  45. }
  46. },
  47. plotOptions: {
  48. solidgauge: {
  49. dataLabels: {
  50. y: -30,
  51. borderWidth: 0,
  52. useHTML: true
  53. }
  54. }
  55. }
  56. };
  57. // The speed gauge
  58. $('#container-speed').highcharts(Highcharts.merge(gaugeOptions, {
  59. yAxis: {
  60. min: 0,
  61. max: 200,
  62. title: {
  63. text: 'Speed'
  64. }
  65. },
  66. credits: {
  67. enabled: false
  68. },
  69. series: [{
  70. name: 'Speed',
  71. data: [80],
  72. dataLabels: {
  73. format: '<div style="text-align:center"><span style="font-size:25px;color:' +
  74. ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>' +
  75. '<span style="font-size:12px;color:silver">km/h</span></div>'
  76. },
  77. tooltip: {
  78. valueSuffix: ' km/h'
  79. }
  80. }]
  81. }));
  82. // The RPM gauge
  83. $('#container-rpm').highcharts(Highcharts.merge(gaugeOptions, {
  84. yAxis: {
  85. min: 0,
  86. max: 5,
  87. title: {
  88. text: 'RPM'
  89. }
  90. },
  91. series: [{
  92. name: 'RPM',
  93. data: [1],
  94. dataLabels: {
  95. format: '<div style="text-align:center"><span style="font-size:25px;color:' +
  96. ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y:.1f}</span><br/>' +
  97. '<span style="font-size:12px;color:silver">* 1000 / min</span></div>'
  98. },
  99. tooltip: {
  100. valueSuffix: ' revolutions/min'
  101. }
  102. }]
  103. }));
  104. // Bring life to the dials
  105. setInterval(function () {
  106. // Speed
  107. var chart = $('#container-speed').highcharts();
  108. if (chart) {
  109. var point = chart.series[0].points[0],
  110. newVal,
  111. inc = Math.round((Math.random() - 0.5) * 100);
  112. newVal = point.y + inc;
  113. if (newVal < 0 || newVal > 200) {
  114. newVal = point.y - inc;
  115. }
  116. point.update(newVal);
  117. }
  118. // RPM
  119. chart = $('#container-rpm').highcharts();
  120. if (chart) {
  121. var point = chart.series[0].points[0],
  122. newVal,
  123. inc = Math.random() - 0.5;
  124. newVal = point.y + inc;
  125. if (newVal < 0 || newVal > 5) {
  126. newVal = point.y - inc;
  127. }
  128. point.update(newVal);
  129. }
  130. }, 2000);
  131. });
  132. </script>
  133. </head>
  134. <body>
  135. <script src="../../js/highcharts.js"></script>
  136. <script src="../../js/highcharts-more.js"></script>
  137. <script src="../../js/modules/solid-gauge.src.js"></script>
  138. <div style="width: 600px; height: 400px; margin: 0 auto">
  139. <div id="container-speed" style="width: 300px; height: 200px; float: left"></div>
  140. <div id="container-rpm" style="width: 300px; height: 200px; float: left"></div>
  141. </div>
  142. </body>
  143. </html>