123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- <!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;
- }
- @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"),
- {
- min: -100,
- max: 100,
- dialStartAngle: 180,
- dialEndAngle: 0,
- value: 50,
- viewBox: "0 0 100 57",
- color: function(value) {
- if(value < 20) {
- return "#5ee432";
- }else if(value < 40) {
- return "#fffa50";
- }else if(value < 60) {
- return "#f7aa38";
- }else {
- return "#ef4655";
- }
- }
- }
- );
- </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,
- viewBox: "0 0 57 57",
- 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,
- viewBox: "0 35 100 100",
- 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,
- dialRadius: 150,
- showValue: 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 pad = function(tar) {}
- 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 * 100) / 100) + "/" + this.max;
- }
- }
- );
- var gauge2 = Gauge(
- document.getElementById("gauge2"),
- {
- min: -100,
- max: 100,
- dialStartAngle: 180,
- dialEndAngle: 0,
- value: 50,
- viewBox: "0 0 100 57",
- color: function(value) {
- if(value < 20) {
- return "#5ee432";
- }else if(value < 40) {
- return "#fffa50";
- }else if(value < 60) {
- return "#f7aa38";
- }else {
- return "#ef4655";
- }
- }
- }
- );
- var gauge3 = Gauge(
- document.getElementById("gauge3"),
- {
- max: 100,
- value: 50
- }
- );
- var gauge4 = Gauge(
- document.getElementById("gauge4"),
- {
- max: 100,
- dialStartAngle: 180,
- dialEndAngle: -90,
- viewBox: "0 0 60 60",
- value: 50
- }
- );
- var gauge5 = Gauge(
- document.getElementById("gauge5"),
- {
- max: 200,
- dialStartAngle: 0,
- dialEndAngle: -180,
- viewBox: "0 35 100 100",
- value: 50
- }
- );
- var gauge6 = Gauge(
- document.getElementById("gauge6"),
- {
- max: 100,
- dialStartAngle: 90.01,
- dialEndAngle: 89.99,
- dialRadius: 15,
- showValue: false,
- value: 100
- }
- );
- (function loop() {
- var value1 = Math.random() * 100,
- value2 = Math.random(),
- value3 = Math.random() * 100,
- value4 = Math.random() * 100,
- value5 = Math.random() * 200;
- gauge0.setValue(value1, 1);
- gauge1.setValueAnimated(value1, 1);
- gauge2.setValueAnimated(50 - value1, 3);
- gauge3.setValueAnimated(value3, 1.5);
- gauge4.setValueAnimated(value4, 2);
- gauge5.setValueAnimated(value5, 1);
- gauge6.setValueAnimated(value1, 1);
- window.setTimeout(loop, 4000);
- })();
- </script>
- </body>
- </html>
|