Debian Codegraph @

debian/missing-sources/epoch/tests/render/real-time/options.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 <script src="../js/data.js"></script>
9 <link rel="stylesheet" type="text/css" href="../../../dist/css/epoch.css">
10 <style>
11 body { background: #333; color: #d0d0d0; }
12 a:link, a:visited { color: white; color: white; }
13 </style>
14 </head>
15 <body class="epoch-theme-dark">
16 <h1>Real-time Chart Options and Events</h1>
17 <p class="breadcrumbs"><a href="../index.html">Epoch Chart Tests</a> &raquo; Real-time Options and Events</p>
18 <ol>
19 <li><a href="#test-1">Resize</a></li>
20 <li><a href="#test-2">Axes</a></li>
21 <li><a href="#test-3">Ticks</a></li>
22 <li><a href="#test-4">Tick Formats</a></li>
23 <li><a href="#test-5">Margins</a></li>
24 </ol>
25
26 <!-- Test 1 -->
27 <div id="test-1" class="test">
28 <h2>1. Resize</h2>
29 <p>Correctly Resize a Real-time Chart.</p>
30 <div class="epoch"></div>
31 <p>
32 <button class="playback">Play</button> |
33 <button class="size" data-index="0">Size: Small</button>
34 <button class="size" data-index="1">Size: Medium</button>
35 <button class="size" data-index="2">Size: Large</button>
36 </p>
37 </div>
38 <script>
39 $(function() {
40 var step = Math.PI / 30,
41 data = time().add(function(x) { return Math.cos(x) + 1; }),
42 interval = null;
43
44 var sizes = [
45 { width: 400, height: 100 },
46 { width: 800, height: 150 },
47 { width: $('#test-1 .epoch').width(), height: $('#test-1 .epoch').height() }
48 ];
49
50 var chart = $('#test-1 .epoch').epoch({
51 type: 'time.line',
52 data: data.get([0, 2*Math.PI], step)
53 })
54
55 function pushPoint() {
56 chart.push(data.next(step));
57 }
58
59 $('#test-1 .playback').click(function(e) {
60 if (!interval) {
61 interval = setInterval(function() { pushPoint() }, 1000);
62 pushPoint();
63 $('#test-1 .playback').text('Pause');
64 }
65 else {
66 clearInterval(interval);
67 interval = null;
68 $('#test-1 .playback').text('Play');
69 }
70 });
71
72 $('#test-1 .size').click(function(e) {
73 var size = sizes[parseInt($(e.target).attr('data-index'))];
74 chart.option('width', size.width);
75 chart.option('height', size.height);
76 });
77 });
78 </script>
79
80 <!-- Test 2 -->
81 <div id="test-2" class="test">
82 <h2>2. Axes</h2>
83 <div class="epoch"></div>
84 <div class="controls">
85 <button class="playback">Play</button> |
86 <button class="axes" data-index="0">All</button>
87 <button class="axes" data-index="1">[left, right]</button>
88 <button class="axes" data-index="2">[top, bottom]</button>
89 <button class="axes" data-index="3">[left, bottom]</button>
90 <button class="axes" data-index="4">[top, right]</button>
91 <button class="axes" data-index="5">None</button>
92 </div>
93 </div>
94 <script>
95 $(function() {
96 var step = Math.PI / 30,
97 data = time().add(function(x) { return Math.sin(x) + 1; }),
98 interval = null;
99
100 var axes = [
101 ['top', 'left', 'bottom', 'right'],
102 ['left', 'right'],
103 ['top', 'bottom'],
104 ['left', 'bottom'],
105 ['top', 'right'],
106 []
107 ];
108
109 var chart = $('#test-2 .epoch').epoch({
110 type: 'time.line',
111 data: data.get([0, 2*Math.PI], step)
112 })
113
114 function pushPoint() {
115 chart.push(data.next(step));
116 }
117
118 $('#test-2 .playback').click(function(e) {
119 if (!interval) {
120 interval = setInterval(function() { pushPoint() }, 1000);
121 pushPoint();
122 $('#test-2 .playback').text('Pause');
123 }
124 else {
125 clearInterval(interval);
126 interval = null;
127 $('#test-2 .playback').text('Play');
128 }
129 });
130
131 $('#test-2 button.axes').click(function(e) {
132 chart.option('axes', axes[parseInt($(e.target).attr('data-index'))]);
133 });
134 });
135 </script>
136
137 <!-- Test 3 -->
138 <div id="test-3" class="test">
139 <h2>3. Ticks</h2>
140 <div class="epoch"></div>
141 <p>
142 <button class="playback">Play</button> |
143 <button class="ticks" data-index="0">Normal</button>
144 <button class="ticks" data-index="1">Many</button>
145 </p>
146 </div>
147 <script>
148 $(function() {
149 var step = Math.PI / 30,
150 data = time().add(function(x) { return Math.sqrt(x) * Math.sin(x) + 1; }),
151 interval = null;
152
153 var ticks = [
154 {time: 15, left: 5, right: 5},
155 {time: 5, left: 15, right: 15}
156 ];
157
158 var chart = $('#test-3 .epoch').epoch({
159 type: 'time.line',
160 data: data.get([0, 2*Math.PI], step),
161 axes: ['top', 'left', 'bottom', 'right']
162 })
163
164 function pushPoint() {
165 chart.push(data.next(step));
166 }
167
168 $('#test-3 .playback').click(function(e) {
169 if (!interval) {
170 interval = setInterval(function() { pushPoint() }, 1000);
171 pushPoint();
172 $('#test-3 .playback').text('Pause');
173 }
174 else {
175 clearInterval(interval);
176 interval = null;
177 $('#test-3 .playback').text('Play');
178 }
179 });
180
181 $('#test-3 .ticks').click(function(e) {
182 chart.option('ticks', ticks[parseInt($(e.target).attr('data-index'))]);
183 });
184 });
185 </script>
186
187 <!-- Test 4 -->
188 <div id="test-4" class="test">
189 <h2>4. Tick Formats</h2>
190 <div class="epoch"></div>
191 <p>
192 <button class="playback">Play</button> |
193 <button class="tickFormats" data-index="0">Normal</button>
194 <button class="tickFormats" data-index="1">Different</button>
195 </p>
196 </div>
197 <script>
198 $(function() {
199 var step = Math.PI / 30,
200 data = time().add(function(x) { return Math.abs(Math.sin(x)); }),
201 interval = null;
202
203 var tickFormats = [
204 {
205 top: Epoch.Formats.seconds,
206 bottom: Epoch.Formats.seconds,
207 left: Epoch.Formats.si,
208 right: Epoch.Formats.si
209 },
210 {
211 top: Epoch.Formats.si,
212 bottom: Epoch.Formats.si,
213 left: Epoch.Formats.percent,
214 right: Epoch.Formats.percent
215 }
216 ];
217
218 var chart = $('#test-4 .epoch').epoch({
219 type: 'time.area',
220 data: data.get([0, 2*Math.PI], step),
221 axes: ['top', 'left', 'bottom', 'right']
222 })
223
224 function pushPoint() {
225 chart.push(data.next(step));
226 }
227
228 $('#test-4 .playback').click(function(e) {
229 if (!interval) {
230 interval = setInterval(function() { pushPoint() }, 1000);
231 pushPoint();
232 $('#test-4 .playback').text('Pause');
233 }
234 else {
235 clearInterval(interval);
236 interval = null;
237 $('#test-4 .playback').text('Play');
238 }
239 });
240
241 $('#test-4 .tickFormats').click(function(e) {
242 chart.option('tickFormats', tickFormats[parseInt($(e.target).attr('data-index'))]);
243 });
244 });
245 </script>
246
247 <!-- Test 5 -->
248 <div id="test-5" class="test">
249 <h2>5. Margins</h2>
250 <div class="epoch"></div>
251 <p>
252 <button class="playback">Play</button> |
253 <button class="margins" data-index="0">None</button>
254 <button class="margins" data-index="1">Small</button>
255 <button class="margins" data-index="2">Big</button>
256 </p>
257 </div>
258 <script>
259 $(function() {
260 var step = Math.PI / 30,
261 data = time().add(function(x) { return 1 - Math.abs(Math.cos(x)); }),
262 interval = null;
263
264 var margins = [
265 { top: 6, bottom: 6, left: 6, right: 6 },
266 { top: 20, bottom: 20, left: 20, right: 20 },
267 { top: 100, bottom: 50, left: 50, right: 50 }
268 ];
269
270 var chart = $('#test-5 .epoch').epoch({
271 type: 'time.area',
272 data: data.get([0, 2*Math.PI], step),
273 axes: []
274 })
275
276 function pushPoint() {
277 chart.push(data.next(step));
278 }
279
280 $('#test-5 .playback').click(function(e) {
281 if (!interval) {
282 interval = setInterval(function() { pushPoint() }, 1000);
283 pushPoint();
284 $('#test-5 .playback').text('Pause');
285 }
286 else {
287 clearInterval(interval);
288 interval = null;
289 $('#test-5 .playback').text('Play');
290 }
291 });
292
293 $('#test-5 .margins').click(function(e) {
294 chart.option('margins', margins[parseInt($(e.target).attr('data-index'))]);
295 });
296 });
297 </script>
298 </body>
299 </html>