index.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Gauges</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  7. <meta name="HandheldFriendly" content="True" />
  8. <meta name="MobileOptimized" content="480" />
  9. <meta name="viewport"
  10. content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  11. <meta name="apple-mobile-web-app-capable" content="yes" />
  12. <meta name="theme-color" content="#2f434e" />
  13. <meta http-equiv="cleartype" content="on" />
  14. <link rel="stylesheet" href="index.css" />
  15. <link rel="stylesheet" href="dark.css" />
  16. <style>
  17. .example {
  18. overflow: auto;
  19. padding: 10px;
  20. box-sizing: border-box;
  21. clear: both;
  22. }
  23. .example > .code, .example > .display {
  24. box-sizing: border-box;
  25. padding: 10px;
  26. }
  27. .example > .code {
  28. }
  29. .example > .display {
  30. text-align: center;
  31. overflow: auto;
  32. padding: 20px 0;
  33. overflow: hidden;
  34. }
  35. .example > .display {
  36. }
  37. pre {
  38. padding: 0;
  39. margin: 0;
  40. }
  41. #gauge1 .value-text {
  42. font-size: 6em;
  43. }
  44. @media only screen and (min-device-width: 768px) {
  45. .example > .code {
  46. width: 65%;
  47. }
  48. .example > .display {
  49. width: 35%;
  50. }
  51. .example > .code {
  52. float: left;
  53. }
  54. .example > .display {
  55. float: right;
  56. padding: 10px;
  57. }
  58. }
  59. </style>
  60. <script type="text/javascript" src="highlight.pack.js"> </script>
  61. <script>hljs.initHighlightingOnLoad();</script>
  62. </head>
  63. <body>
  64. <h2>SVG Gauge</h2>
  65. <h4>Minimalistic, zero dependency animated gauge widget</h4>
  66. <p>
  67. All the guages are styled via CSS. See gauge-test.css for styling for each of these gauges
  68. below.
  69. </p>
  70. <div class="example">
  71. <div class="code">
  72. <pre>
  73. <code class="html">
  74. &lt;!-- Unstyled gauge (All defaults) --&gt;
  75. &lt;div id="gauge0" class="gauge-container"&gt;&lt;/div&gt;
  76. </code>
  77. <code class="javascript">
  78. var gauge0 = Gauge(document.getElementById("gauge0"));
  79. </code>
  80. </pre>
  81. </div>
  82. <div class="display">
  83. <div id="gauge0" class="gauge-container"></div>
  84. </div>
  85. </div>
  86. <div class="example">
  87. <div class="code">
  88. <pre>
  89. <code class="html"> &lt;div id="gauge1" class="gauge-container"&gt;&lt;/div&gt;</code>
  90. <code class="javascript">
  91. var gauge1 = Gauge(
  92. document.getElementById("gauge1"),
  93. {
  94. max: 100,
  95. dialStartAngle: -90,
  96. dialEndAngle: -90.001,
  97. value: 100,
  98. label: function(value) {
  99. return Math.round(value) + "/" + this.max;
  100. }
  101. }
  102. );
  103. </code>
  104. </pre>
  105. </div>
  106. <div class="display">
  107. <div id="gauge1" class="gauge-container one"></div>
  108. </div>
  109. </div>
  110. <div class="example">
  111. <div class="code">
  112. <pre>
  113. <code class="html">
  114. &lt;div id="gauge2" class="gauge-container two"&gt;&lt;/div&gt;
  115. </code>
  116. <code class="javascript">
  117. var gauge2 = Gauge(
  118. document.getElementById("gauge2"),
  119. {
  120. max: 100,
  121. dialStartAngle: 180,
  122. dialEndAngle: 0,
  123. value: 50
  124. }
  125. );
  126. </code>
  127. </pre>
  128. </div>
  129. <div class="display">
  130. <div id="gauge2" class="gauge-container two"></div>
  131. </div>
  132. </div>
  133. <div class="example">
  134. <div class="code">
  135. <pre>
  136. <code class="html">
  137. &lt;div id="gauge3" class="gauge-container three"&gt;&lt;/div&gt;
  138. </code>
  139. <code class="javascript">
  140. var gauge3 = Gauge(
  141. document.getElementById("gauge3"),
  142. {
  143. max: 100,
  144. value: 50
  145. }
  146. );
  147. </code>
  148. </pre>
  149. </div>
  150. <div class="display">
  151. <div id="gauge3" class="gauge-container three"></div>
  152. </div>
  153. </div>
  154. <div class="example">
  155. <div class="code">
  156. <pre>
  157. <code class="html">
  158. &lt;div id="gauge4" class="gauge-container four"&gt;&lt;/div&gt;
  159. </code>
  160. <code class="javascript">
  161. var gauge4 = Gauge(
  162. document.getElementById("gauge4"),
  163. {
  164. max: 100,
  165. dialStartAngle: 180,
  166. dialEndAngle: -90,
  167. value: 50
  168. }
  169. );
  170. </code>
  171. </pre>
  172. </div>
  173. <div class="display">
  174. <div id="gauge4" class="gauge-container four"></div>
  175. </div>
  176. </div>
  177. <div class="example">
  178. <div class="code">
  179. <pre>
  180. <code class="html">
  181. &lt;div id="gauge5" class="gauge-container five"&gt;&lt;/div&gt;
  182. </code>
  183. <code class="javascript">
  184. var gauge5 = Gauge(
  185. document.getElementById("gauge5"),
  186. {
  187. max: 200,
  188. dialStartAngle: 0,
  189. dialEndAngle: -180,
  190. value: 50
  191. }
  192. );
  193. </code>
  194. </pre>
  195. </div>
  196. <div class="display">
  197. <div id="gauge5" class="gauge-container five"></div>
  198. </div>
  199. </div>
  200. <div class="example">
  201. <div class="code">
  202. <pre>
  203. <code class="html">
  204. &lt;div id="gauge6" class="gauge-container six"&gt;&lt;/div&gt;
  205. </code>
  206. <code class="javascript">
  207. var gauge6 = Gauge(
  208. document.getElementById("gauge6"),
  209. {
  210. max: 100,
  211. dialStartAngle: 90.01,
  212. dialEndAngle: 89.99,
  213. radius: 150,
  214. displayValue: false,
  215. value: 50,
  216. }
  217. );
  218. </code>
  219. </pre>
  220. </div>
  221. <div class="display">
  222. <div id="gauge6" class="gauge-container six"></div>
  223. </div>
  224. </div>
  225. <script type="text/javascript" src="../src/gauge.js"> </script>
  226. <script>
  227. var gauge0 = Gauge(document.getElementById("gauge0"));
  228. var gauge1 = Gauge(
  229. document.getElementById("gauge1"),
  230. {
  231. max: 100,
  232. dialStartAngle: -90,
  233. dialEndAngle: -90.001,
  234. value: 100,
  235. label: function(value) {
  236. return Math.round(value) + "/" + this.max;
  237. }
  238. }
  239. );
  240. var gauge2 = Gauge(
  241. document.getElementById("gauge2"),
  242. {
  243. max: 100,
  244. dialStartAngle: 180,
  245. dialEndAngle: 0,
  246. value: 50
  247. }
  248. );
  249. var gauge3 = Gauge(
  250. document.getElementById("gauge3"),
  251. {
  252. max: 100,
  253. value: 50
  254. }
  255. );
  256. var gauge4 = Gauge(
  257. document.getElementById("gauge4"),
  258. {
  259. max: 100,
  260. dialStartAngle: 180,
  261. dialEndAngle: -90,
  262. value: 50
  263. }
  264. );
  265. var gauge5 = Gauge(
  266. document.getElementById("gauge5"),
  267. {
  268. max: 200,
  269. dialStartAngle: 0,
  270. dialEndAngle: -180,
  271. value: 50
  272. }
  273. );
  274. var gauge6 = Gauge(
  275. document.getElementById("gauge6"),
  276. {
  277. max: 100,
  278. dialStartAngle: 90.01,
  279. dialEndAngle: 89.99,
  280. radius: 150,
  281. showValue: false,
  282. value: 100
  283. }
  284. );
  285. (function loop() {
  286. var value1 = Math.round(Math.random() * 100),
  287. value2 = Math.round(Math.random() * 100),
  288. value3 = Math.round(Math.random() * 100),
  289. value4 = Math.round(Math.random() * 100),
  290. value5 = Math.round(Math.random() * 200);
  291. gauge0.setValueAnimated(value1, 1);
  292. gauge1.setValueAnimated(value1, 1);
  293. gauge2.setValueAnimated(value2, 2);
  294. gauge3.setValueAnimated(value3, 1.5);
  295. gauge4.setValueAnimated(value4, 2);
  296. gauge5.setValueAnimated(value5, 1);
  297. gauge6.setValueAnimated(value1, 1);
  298. window.setTimeout(loop, 2500);
  299. })();
  300. </script>
  301. </body>
  302. </html>