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.

112 lines
2.8 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>amCharts examples</title>
  6. <link rel="stylesheet" href="style.css" type="text/css">
  7. <script src="../amcharts/amcharts.js" type="text/javascript"></script>
  8. <script src="../amcharts/gauge.js" type="text/javascript"></script>
  9. <script>
  10. var chart;
  11. var sArrow;
  12. var mArrow;
  13. var hArrow;
  14. var axis;
  15. AmCharts.ready(function () {
  16. // clock is just an angular gauge with three arrows
  17. chart = new AmCharts.AmAngularGauge();
  18. chart.startDuration = 0.3;
  19. // main face
  20. axis = new AmCharts.GaugeAxis();
  21. axis.startValue = 0;
  22. axis.endValue = 12;
  23. axis.valueInterval = 1;
  24. axis.minorTickInterval = 0.2;
  25. axis.showFirstLabel = false;
  26. axis.startAngle = 0;
  27. axis.endAngle = 360;
  28. axis.axisAlpha = 0.3;
  29. chart.addAxis(axis);
  30. // seconds face
  31. var axis2 = new AmCharts.GaugeAxis();
  32. axis2.startValue = 0;
  33. axis2.endValue = 60;
  34. axis2.valueInterval = 15;
  35. axis2.minorTickInterval = 1;
  36. axis2.showFirstLabel = false;
  37. axis2.startAngle = 0;
  38. axis2.endAngle = 360;
  39. axis2.radius = 40;
  40. axis2.centerY = 80;
  41. axis2.inside = false;
  42. axis2.axisAlpha = 0.3;
  43. chart.addAxis(axis2);
  44. // hour arrow
  45. hArrow = new AmCharts.GaugeArrow();
  46. hArrow.radius = "50%";
  47. hArrow.clockWiseOnly = true;
  48. // minutes arrow
  49. mArrow = new AmCharts.GaugeArrow();
  50. mArrow.radius = "90%";
  51. mArrow.startWidth = 6;
  52. mArrow.nailRadius = 0;
  53. mArrow.clockWiseOnly = true;
  54. // seconds arrow
  55. sArrow = new AmCharts.GaugeArrow();
  56. sArrow.axis = axis2; // this arrow uses different axis
  57. sArrow.startWidth = 3;
  58. sArrow.nailRadius = 4;
  59. sArrow.color = "#CC0000";
  60. sArrow.clockWiseOnly = true;
  61. // update clock before adding arrows to avoid initial animation
  62. updateClock();
  63. // add arrows
  64. chart.addArrow(hArrow);
  65. chart.addArrow(mArrow);
  66. chart.addArrow(sArrow);
  67. chart.write("chartdiv");
  68. // update clock every second
  69. setInterval(updateClock, 1000);
  70. });
  71. // update clock
  72. function updateClock() {
  73. // get date
  74. var date = new Date();
  75. var hours = date.getHours();
  76. var minutes = date.getMinutes();
  77. var seconds = date.getSeconds();
  78. // update hours
  79. hArrow.setValue(hours + minutes / 60);
  80. // update minutes
  81. mArrow.setValue(12 * (minutes + seconds / 60) / 60);
  82. // update seconds
  83. sArrow.setValue(date.getSeconds());
  84. // update date
  85. var dateString = AmCharts.formatDate(date, "DD MMM, EEE");
  86. axis.setTopText(dateString);
  87. }
  88. </script>
  89. </head>
  90. <body>
  91. <div id="chartdiv" style="width:400px; height:400px;"></div>
  92. </body>
  93. </html>