gauge.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <script src="http://www.amcharts.com/lib/3/amcharts.js"></script>
  7. <script src="http://www.amcharts.com/lib/3/gauge.js"></script>
  8. <!-- Export plugin includes and styles -->
  9. <script src="../export.js"></script>
  10. <link type="text/css" href="../export.css" rel="stylesheet">
  11. <style>
  12. body, html {
  13. height: 100%;
  14. padding: 0;
  15. margin: 0;
  16. overflow: hidden;
  17. font-size: 11px;
  18. font-family: Verdana;
  19. }
  20. #chartdiv {
  21. width: 100%;
  22. height: 100%;
  23. }
  24. </style>
  25. <script type="text/javascript">
  26. var chart = AmCharts.makeChart( "chartdiv", {
  27. "type": "gauge",
  28. "titles": [ {
  29. "text": "Speedometer",
  30. "size": 15
  31. } ],
  32. "axes": [ {
  33. "startValue": 0,
  34. "axisThickness": 1,
  35. "endValue": 220,
  36. "valueInterval": 10,
  37. "bottomTextYOffset": -20,
  38. "bottomText": "0 km/h",
  39. "bands": [ {
  40. "startValue": 0,
  41. "endValue": 90,
  42. "color": "#00CC00"
  43. }, {
  44. "startValue": 90,
  45. "endValue": 130,
  46. "color": "#ffac29"
  47. }, {
  48. "startValue": 130,
  49. "endValue": 220,
  50. "color": "#ea3838",
  51. "innerRadius": "95%"
  52. } ]
  53. } ],
  54. "arrows": [ {} ],
  55. "export": {
  56. "enabled": true
  57. }
  58. } );
  59. setInterval( randomValue, 2000 );
  60. // set random value
  61. function randomValue() {
  62. var value = Math.round( Math.random() * 200 );
  63. chart.arrows[ 0 ].setValue( value );
  64. chart.axes[ 0 ].setBottomText( value + " km/h" );
  65. }
  66. </script>
  67. </head>
  68. <body>
  69. <div id="chartdiv"></div>
  70. </body>
  71. </html>