123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Gauges</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
- <meta name="HandheldFriendly" content="True" />
- <meta name="MobileOptimized" content="480" />
- <meta name="viewport"
- content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <meta name="theme-color" content="#2f434e" />
- <meta http-equiv="cleartype" content="on" />
- <link rel="stylesheet" href="index.css" />
- <link rel="stylesheet" href="dark.css" />
- <style>
- .example {
- overflow: auto;
- padding: 10px;
- box-sizing: border-box;
- clear: both;
- }
- .example > .code, .example > .display {
- box-sizing: border-box;
- padding: 10px;
- }
- .example > .code {
- }
- .example > .display {
- text-align: center;
- overflow: auto;
- padding: 20px 0;
- overflow: hidden;
- }
- .example > .display {
- }
- pre {
- padding: 0;
- margin: 0;
- }
- #gauge1 .value-text {
- font-size: 6em;
- }
- @media only screen and (min-device-width: 768px) {
- .example > .code {
- width: 65%;
- }
- .example > .display {
- width: 35%;
- }
- .example > .code {
- float: left;
- }
- .example > .display {
- float: right;
- padding: 10px;
- }
- }
- </style>
- <script type="text/javascript" src="highlight.pack.js"> </script>
- <script>hljs.initHighlightingOnLoad();</script>
- </head>
- <body>
- <h2>SVG Gauge</h2>
- <h4>Minimalistic, zero dependency animated gauge widget</h4>
- <p>
- All the guages are styled via CSS. See gauge-test.css for styling for each of these gauges
- below.
- </p>
- <div class="example">
- <div class="code">
- <pre>
- <code class="html">
- <!-- Unstyled gauge (All defaults) -->
- <div id="gauge0" class="gauge-container"></div>
- </code>
- <code class="javascript">
- var gauge0 = Gauge(document.getElementById("gauge0"));
- </code>
- </pre>
- </div>
- <div class="display">
- <div id="gauge0" class="gauge-container"></div>
- </div>
- </div>
- <div class="example">
- <div class="code">
- <pre>
- <code class="html"> <div id="gauge1" class="gauge-container"></div></code>
- <code class="javascript">
- var gauge1 = Gauge(
- document.getElementById("gauge1"),
- {
- max: 100,
- dialStartAngle: -90,
- dialEndAngle: -90.001,
- value: 100,
- label: function(value) {
- return Math.round(value) + "/" + this.max;
- }
- }
- );
- </code>
- </pre>
- </div>
- <div class="display">
- <div id="gauge1" class="gauge-container one"></div>
- </div>
- </div>
- <div class="example">
- <div class="code">
- <pre>
- <code class="html">
- <div id="gauge2" class="gauge-container two"></div>
- </code>
- <code class="javascript">
- var gauge2 = Gauge(
- document.getElementById("gauge2"),
- {
- max: 100,
- dialStartAngle: 180,
- dialEndAngle: 0,
- value: 50
- }
- );
- </code>
- </pre>
- </div>
- <div class="display">
- <div id="gauge2" class="gauge-container two"></div>
- </div>
- </div>
- <div class="example">
- <div class="code">
- <pre>
- <code class="html">
- <div id="gauge3" class="gauge-container three"></div>
- </code>
- <code class="javascript">
- var gauge3 = Gauge(
- document.getElementById("gauge3"),
- {
- max: 100,
- value: 50
- }
- );
- </code>
- </pre>
- </div>
- <div class="display">
- <div id="gauge3" class="gauge-container three"></div>
- </div>
- </div>
- <div class="example">
- <div class="code">
- <pre>
- <code class="html">
- <div id="gauge4" class="gauge-container four"></div>
- </code>
- <code class="javascript">
- var gauge4 = Gauge(
- document.getElementById("gauge4"),
- {
- max: 100,
- dialStartAngle: 180,
- dialEndAngle: -90,
- value: 50
- }
- );
- </code>
- </pre>
- </div>
- <div class="display">
- <div id="gauge4" class="gauge-container four"></div>
- </div>
- </div>
- <div class="example">
- <div class="code">
- <pre>
- <code class="html">
- <div id="gauge5" class="gauge-container five"></div>
- </code>
- <code class="javascript">
- var gauge5 = Gauge(
- document.getElementById("gauge5"),
- {
- max: 200,
- dialStartAngle: 0,
- dialEndAngle: -180,
- value: 50
- }
- );
- </code>
- </pre>
- </div>
- <div class="display">
- <div id="gauge5" class="gauge-container five"></div>
- </div>
- </div>
- <div class="example">
- <div class="code">
- <pre>
- <code class="html">
- <div id="gauge6" class="gauge-container six"></div>
- </code>
- <code class="javascript">
- var gauge6 = Gauge(
- document.getElementById("gauge6"),
- {
- max: 100,
- dialStartAngle: 90.01,
- dialEndAngle: 89.99,
- radius: 150,
- displayValue: false,
- value: 50,
- }
- );
- </code>
- </pre>
- </div>
- <div class="display">
- <div id="gauge6" class="gauge-container six"></div>
- </div>
- </div>
- <script type="text/javascript" src="../src/gauge.js"> </script>
- <script>
- var gauge0 = Gauge(document.getElementById("gauge0"));
- var gauge1 = Gauge(
- document.getElementById("gauge1"),
- {
- max: 100,
- dialStartAngle: -90,
- dialEndAngle: -90.001,
- value: 100,
- label: function(value) {
- return Math.round(value) + "/" + this.max;
- }
- }
- );
- var gauge2 = Gauge(
- document.getElementById("gauge2"),
- {
- max: 100,
- dialStartAngle: 180,
- dialEndAngle: 0,
- value: 50
- }
- );
- var gauge3 = Gauge(
- document.getElementById("gauge3"),
- {
- max: 100,
- value: 50
- }
- );
- var gauge4 = Gauge(
- document.getElementById("gauge4"),
- {
- max: 100,
- dialStartAngle: 180,
- dialEndAngle: -90,
- value: 50
- }
- );
- var gauge5 = Gauge(
- document.getElementById("gauge5"),
- {
- max: 200,
- dialStartAngle: 0,
- dialEndAngle: -180,
- value: 50
- }
- );
- var gauge6 = Gauge(
- document.getElementById("gauge6"),
- {
- max: 100,
- dialStartAngle: 90.01,
- dialEndAngle: 89.99,
- radius: 150,
- showValue: false,
- value: 100
- }
- );
- (function loop() {
- var value1 = Math.round(Math.random() * 100),
- value2 = Math.round(Math.random() * 100),
- value3 = Math.round(Math.random() * 100),
- value4 = Math.round(Math.random() * 100),
- value5 = Math.round(Math.random() * 200);
- gauge0.setValueAnimated(value1, 1);
- gauge1.setValueAnimated(value1, 1);
- gauge2.setValueAnimated(value2, 2);
- gauge3.setValueAnimated(value3, 1.5);
- gauge4.setValueAnimated(value4, 2);
- gauge5.setValueAnimated(value5, 1);
- gauge6.setValueAnimated(value1, 1);
- window.setTimeout(loop, 2500);
- })();
- </script>
- </body>
- </html>
|