Debian Codegraph @

debian/missing-sources/epoch/tests/render/real-time/gauge.html

raw
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="stylesheet" type="text/css" href="../css/tests.css">
5 <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
6 <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
7 <script src="../../../dist/js/epoch.js"></script>
8 <link rel="stylesheet" type="text/css" href="../../../dist/css/epoch.css">
9
10 <script>
11 var nextTime = (function() {
12 var currentTime = parseInt(new Date().getTime() / 1000);
13 return function() { return currentTime++; }
14 })();
15 </script>
16 </head>
17 <body>
18 <h1>Real-time Gauge Test</h1>
19 <p class="breadcrumbs"><a href="../index.html">Epoch Chart Tests</a> &raquo; Real-time Gauge</p>
20 <ol>
21 <li><a href="#test-1">Single Value Display</a></li>
22 <li><a href="#test-2">Single Transition</a></li>
23 <li><a href="#test-3">Stream Transition</a></li>
24 <li><a href="#test-4">Gauge Sizes</a></li>
25 <li><a href="#test-5">Color Override</a></li>
26 <li><a href="test-6">Option: domain</a></li>
27 <li><a href="test-7">Option: ticks</a></li>
28 <li><a href="test-8">Option: tickSize</a></li>
29 <li><a href="test-9">Option: tickOffset</a></li>
30 <li><a href="test-10">Option: format</a></li>
31 </ol>
32
33 <!-- Test 1 -->
34 <div id="test-1" class="test">
35 <h2>1. Single Value Display</h2>
36 <p>Display a single value of 25%</p>
37 <div class="epoch gauge-small"></div>
38 </div>
39 <script>
40 $(function() {
41 $('#test-1 .epoch').epoch({ type: 'time.gauge', value: 0.25 });
42 });
43 </script>
44
45
46 <!-- Test 2 -->
47 <div id="test-2" class="test">
48 <h2>2. Single Transition</h2>
49 <p>Display value of 0% and transition to a random value when the button is pressed.</p>
50 <div class="epoch gauge-small"></div>
51 <p><button>Transition</button></p>
52 </div>
53 <script>
54 $(function() {
55 var chart = $('#test-2 .epoch').epoch({
56 type: 'time.gauge',
57 value: 0.0
58 });
59
60 $('#test-2 button').on('click', function(e) {
61 chart.update(Math.random());
62 });
63 });
64 </script>
65
66
67 <!-- Test 3 -->
68 <div id="test-3" class="test">
69 <h2>3. Stream Transition</h2>
70 <p>Display value of 0% and transition to a random value every second when the button is pressed.</p>
71 <div class="epoch gauge-small"></div>
72 <p><button>Play</button></p>
73 </div>
74 <script>
75 $(function() {
76 var chart = $('#test-3 .epoch').epoch({
77 type: 'time.gauge',
78 value: 0.0
79 }),
80 playing = false,
81 interval = null;
82
83 $('#test-3 button').on('click', function(e) {
84 if (interval === null) {
85 interval = setInterval(function() {
86 chart.update(Math.random());
87 }, 1000);
88 chart.update(Math.random());
89 $(e.target).text('Pause');
90 }
91 else {
92 clearInterval(interval);
93 interval = null;
94 $(e.target).text('Play');
95 }
96 });
97 });
98 </script>
99
100 <!-- Test 4 -->
101 <div id="test-4" class="test">
102 <h2>4. Gauge Sizes</h2>
103 <p>Display the four built-in gauge sizes in this order: tiny, small, medium, large.</p>
104 <div class="epoch gauge-tiny"></div>
105 <div class="epoch gauge-small"></div>
106 <div class="epoch gauge-medium"></div>
107 <div class="epoch gauge-large"></div>
108 </div>
109 <script>
110 $(function() {
111 $('#test-4 .gauge-tiny').epoch({ type: 'time.gauge', value: 0.75 });
112 $('#test-4 .gauge-small').epoch({ type: 'time.gauge', value: 0.75 });
113 $('#test-4 .gauge-medium').epoch({ type: 'time.gauge', value: 0.75 });
114 $('#test-4 .gauge-large').epoch({ type: 'time.gauge', value: 0.75 });
115 });
116 </script>
117
118 <!-- Test 5 -->
119 <div id="test-5" class="test">
120 <h2>5. Color Override</h2>
121 <p>
122 Override the basic gauge styles with the following
123 <ul>
124 <li>Outer arc 8px thickness colored green</li>
125 <li>Inner arc 2px thickness colored orange</li>
126 <li>Ticks should be 3px in width and red</li>
127 <li>Needle colored blue.</li>
128 <li>Needle base colored black</li>
129 </ul>
130 </p>
131 <div id="test-5-plot" class="epoch gauge-medium"></div>
132 </div>
133
134 <style>
135 #test-5-plot .epoch .gauge .arc.outer {
136 stroke-width: 8px;
137 stroke: green;
138 }
139
140 #test-5-plot .epoch .gauge .arc.inner {
141 stroke-width: 2px;
142 stroke: orange;
143 }
144
145 #test-5-plot .epoch .gauge .tick {
146 stroke-width: 3px;
147 stroke: red;
148 }
149
150 #test-5-plot .epoch .gauge .needle {
151 fill: blue;
152 }
153
154 #test-5-plot .epoch .gauge .needle-base {
155 fill: black;
156 }
157 </style>
158
159 <script>
160 $(function() {
161 $('#test-5 .epoch').epoch({ type: 'time.gauge', value: 0.5 });
162 });
163 </script>
164
165 <!--
166 Common Option Event Listener Events
167 -->
168 <script>
169 window.makeOptionTest = function(testNumber, chartOptions, optionName) {
170 chartOptions = chartOptions ? chartOptions : {};
171
172 if (!chartOptions.type)
173 chartOptions.type = 'time.gauge';
174 if (!chartOptions.value)
175 chartOptions.value = 0.5;
176 if (!chartOptions.domain)
177 chartOptions.domain = [0, 1];
178
179 var domain = chartOptions.domain,
180 id = '#test-' + testNumber,
181 chart = $(id + ' .epoch').epoch(chartOptions),
182 interval = null,
183 next = function() { chart.push(Math.random()*(domain[1] - domain[0]) + domain[0]); };
184
185 $(id + ' .playback').click(function(e) {
186 if (!interval) {
187 interval = setInterval(next, 1500);
188 next();
189 $(e.target).text('Pause');
190 }
191 else {
192 clearInterval(interval);
193 interval = null;
194 $(e.target).text('Play');
195 }
196 });
197
198 var formats = [
199 Epoch.Formats.percent,
200 function(d) { return d.toFixed(2); }
201 ];
202
203 $(id + ' .option').click(function(e) {
204 var value = parseInt($(e.target).attr('data-value'));
205
206 console.log(optionName, value);
207
208 if (optionName == 'domain')
209 value = domain = $(e.target).attr('data-value').split(',').map(function(d) { return parseInt(d); });
210 else if (optionName == 'format')
211 value = formats[value];
212 chart.option(optionName, value);
213 });
214 };
215 </script>
216
217
218 <!-- Test 6 -->
219 <div id="test-6" class="test">
220 <h2>6. Option: domain</h2>
221 <div class="epoch gauge-small"></div>
222 <p>
223 <button class="playback">Play</button> |
224 <button class="option" data-value="0,1">[0, 1]</button>
225 <button class="option" data-value="0,2">[0, 2]</button>
226 </p>
227 </div>
228 <script>$(function() { makeOptionTest(6, {}, 'domain'); });</script>
229
230 <!-- Test 7 -->
231 <div id="test-7" class="test">
232 <h2>7. Option: ticks</h2>
233 <div class="epoch gauge-small"></div>
234 <p>
235 <button class="playback">Play</button> |
236 <button class="option" data-value="5">5 Ticks</button>
237 <button class="option" data-value="10">10 Ticks</button>
238 <button class="option" data-value="20">20 Ticks</button>
239 <button class="option" data-value="40">40 Ticks</button>
240 </p>
241 </div>
242 <script>$(function() { makeOptionTest(7, {}, 'ticks'); });</script>
243
244 <!-- Test 8 -->
245 <div id="test-8" class="test">
246 <h2>8. Option: tickSize</h2>
247 <div class="epoch gauge-small"></div>
248 <p>
249 <button class="playback">Play</button> |
250 <button class="option" data-value="2">2px</button>
251 <button class="option" data-value="5">5px</button>
252 <button class="option" data-value="10">10px</button>
253 <button class="option" data-value="20">20px</button>
254 </p>
255 </div>
256 <script>$(function() { makeOptionTest(8, {}, 'tickSize'); });</script>
257
258 <!-- Test 9 -->
259 <div id="test-9" class="test">
260 <h2>9. Option: tickOffset</h2>
261 <div class="epoch gauge-small"></div>
262 <p>
263 <button class="playback">Play</button> |
264 <button class="option" data-value="5">5px</button>
265 <button class="option" data-value="10">10px</button>
266 <button class="option" data-value="20">20px</button>
267 </p>
268 </div>
269 <script>$(function() { makeOptionTest(9, {}, 'tickOffset'); });</script>
270
271 <!-- Test 10 -->
272 <div id="test-10" class="test">
273 <h2>10. Option: format</h2>
274 <div class="epoch gauge-small"></div>
275 <p>
276 <button class="playback">Play</button> |
277 <button class="option" data-value="0">Percent</button>
278 <button class="option" data-value="1">Normal</button>
279 </p>
280 </div>
281 <script>$(function() { makeOptionTest(10, {}, 'format'); });</script>
282 </body>
283 </html>