-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathexamplesAppl.html
More file actions
359 lines (315 loc) · 17.5 KB
/
examplesAppl.html
File metadata and controls
359 lines (315 loc) · 17.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Examples for progresspiesvgAppl.js</title>
<!-- Include Highlighter script (used only for displaying example code in the HTML document) -->
<link rel="stylesheet" href="lib/highlight-styles/github.css">
<script src="lib/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<!-- Include jQuery, the progresspie-plugin and the progresspieAppl-Script -->
<script type="text/javascript" src="lib/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/min/jquery-progresspiesvg-min.js"></script>
<script type="text/javascript" src="js/min/progresspiesvgAppl-min.js"></script>
<script type="text/javascript" src="examples.js"></script>
<link type="text/css" rel="stylesheet" href="examples.css">
<!-- Usually, including the three scripts above is all that's necessary.
The following script code is only needed for two special examples. -->
<script type="text/javascript">
//1. Function for the data-piecolor-function example
function colorGt50(percent) {
var p = percent <= 50 ? 0 : 2 * (percent - 50);
return $.fn.progressPie.colorByPercent(p);
}
//2. Script code for the animation/update example
var timerVal = 0;
var timerRunning = false;
function startStopTimer() {
timerRunning = !timerRunning;
if (timerRunning) {
timer();
}
}
function timer() {
if (timerRunning) {
timerVal+= 1;
if (timerVal > 100) {
timerVal = 0;
}
$("#update1").text(timerVal);
$("#update2").text("%").attr("data-percent", timerVal);
progressPies.draw();
if (timerVal < 100)
window.setTimeout(timer, 400);
else
timerRunning = false;
}
}
</script>
</head>
<body>
<h1>Examples for indirect use of jquery-progresspiesvg.js via progresspiesvgAppl.js</h1>
<h2>Default mode:</h2>
<pre><code class="language-html"><span class="progresspie">100</span> %</code></pre>
<p><span class="progresspie">0</span> %
<span class="progresspie">5</span> %
<span class="progresspie">25</span> %
<span class="progresspie">42</span> %
<span class="progresspie">50</span> %
<span class="progresspie">65</span> %
<span class="progresspie">80</span> %
<span class="progresspie">99</span> %
<span class="progresspie">100</span> %</p>
<pre><code class="language-html"><span class="progressring">100</span> %</code></pre>
<p><span class="progressring">0</span> %
<span class="progressring">5</span> %
<span class="progressring">25</span> %
<span class="progressring">42</span> %
<span class="progressring">50</span> %
<span class="progressring">65</span> %
<span class="progressring">80</span> %
<span class="progressring">99</span> %
<span class="progressring">100</span> %</p>
<h2>Predefined modes</h2>
<h3>Color mode (dynamic color)</h3>
<pre><code class="language-html"><span class="progresspie color">100</span> %</code></pre>
<p> <span class="progresspie color">0</span> %
<span class="progresspie color">5</span> %
<span class="progresspie color">25</span> %
<span class="progresspie color">42</span> %
<span class="progresspie color">50</span> %
<span class="progresspie color">65</span> %
<span class="progresspie color">80</span> %
<span class="progresspie color">99</span> %
<span class="progresspie color">100</span> %</p>
<pre><code class="language-html"><span class="progressring color">100</span> %</code></pre>
<p> <span class="progressring color">0</span> %
<span class="progressring color">5</span> %
<span class="progressring color">25</span> %
<span class="progressring color">42</span> %
<span class="progressring color">50</span> %
<span class="progressring color">65</span> %
<span class="progressring color">80</span> %
<span class="progressring color">99</span> %
<span class="progressring color">100</span> %</p>
<h3>Green mode (static color)</h3>
<pre><code class="language-html"><span class="progresspie green">100</span> %</code></pre>
<p> <span class="progresspie green">0</span> %
<span class="progresspie green">5</span> %
<span class="progresspie green">25</span> %
<span class="progresspie green">42</span> %
<span class="progresspie green">50</span> %
<span class="progresspie green">65</span> %
<span class="progresspie green">80</span> %
<span class="progresspie green">99</span> %
<span class="progresspie green">100</span> %</p>
<pre><code class="language-html"><span class="progressring green">100</span> %</code></pre>
<p> <span class="progressring green">0</span> %
<span class="progressring green">5</span> %
<span class="progressring green">25</span> %
<span class="progressring green">42</span> %
<span class="progressring green">50</span> %
<span class="progressring green">65</span> %
<span class="progressring green">80</span> %
<span class="progressring green">99</span> %
<span class="progressring green">100</span> %</p>
<h3>Red mode (static color)</h3>
<pre><code class="language-html"><span class="progresspie red">100</span> %</code></pre>
<p> <span class="progresspie red">0</span> %
<span class="progresspie red">5</span> %
<span class="progresspie red">25</span> %
<span class="progresspie red">42</span> %
<span class="progresspie red">50</span> %
<span class="progresspie red">65</span> %
<span class="progresspie red">80</span> %
<span class="progresspie red">99</span> %
<span class="progresspie red">100</span> %</p>
<pre><code class="language-html"><span class="progressring red">100</span> %</code></pre>
<p> <span class="progressring red">0</span> %
<span class="progressring red">5</span> %
<span class="progressring red">25</span> %
<span class="progressring red">42</span> %
<span class="progressring red">50</span> %
<span class="progressring red">65</span> %
<span class="progressring red">80</span> %
<span class="progressring red">99</span> %
<span class="progressring red">100</span> %</p>
<h2>Advanced: User-defined colors</h2>
<h3>User-defined static color and demonstration of valign</h3>
<p>The following example shows alternating pies with and without the <code>vcenter</code> class in a line
with a line-height greater than the font-size (so that alignment makes a difference). Also, the last three
lines show different possible notations for color values (not with equivalent color, as you may have noticed).</p>
<pre><code class="language-html"><p style="line-height: 2em">
<span class="progresspie vcenter" data-piecolor="#93A">0</span> %
<span class="progresspie" data-piecolor="#93A">5</span> %
…
<span class="progresspie vcenter" data-piecolor="rgb(180,30,200)">80</span> %
<span class="progresspie" data-piecolor="rgb(200,50,220)">99</span> %
<span class="progresspie vcenter" data-piecolor="#9030A0">100</span> %</p>
</p></code></pre>
<p style="line-height: 2em">
<span class="progresspie vcenter" data-piecolor="#93A">0</span> %
<span class="progresspie" data-piecolor="#93A">5</span> %
<span class="progresspie vcenter" data-piecolor="#93A">25</span> %
<span class="progresspie" data-piecolor="#93A">42</span> %
<span class="progresspie vcenter" data-piecolor="#93A">50</span> %
<span class="progresspie" data-piecolor="#93A">65</span> %
<span class="progresspie vcenter" data-piecolor="rgb(180,30,200)">80</span> %
<span class="progresspie" data-piecolor="rgb(200,50,220)">99</span> %
<span class="progresspie vcenter" data-piecolor="#9030A0">100</span> %</p>
<p>The same with class <code>progressring</code> instead of <code>progresspie</code>:</p>
<p style="line-height: 2em">
<span class="progressring vcenter" data-piecolor="#93A">0</span> %
<span class="progressring" data-piecolor="#93A">5</span> %
<span class="progressring vcenter" data-piecolor="#93A">25</span> %
<span class="progressring" data-piecolor="#93A">42</span> %
<span class="progressring vcenter" data-piecolor="#93A">50</span> %
<span class="progressring" data-piecolor="#93A">65</span> %
<span class="progressring vcenter" data-piecolor="rgb(180,30,200)">80</span> %
<span class="progressring" data-piecolor="rgb(200,50,220)">99</span> %
<span class="progressring vcenter" data-piecolor="#9030A0">100</span> %</p>
<h3><code>data-piecolor-function</code> Attribute</h3>
<p>This example shows a color function which utilizes the default colorByPercent function used in color mode,
but modifies the mapping so that all values less than 50% get drawn in red and all the other colors
are only used for greater values:</p>
<pre><code class="language-html"><head>
…
<script type="text/javascript">
function colorGt50(percent) {
var p = percent <= 50 ? 0 : 2 * (percent - 50);
return $.fn.progressPie.colorByPercent(p);
}
</script>
…
</head>
…
<body>
…
<span class="progresspie" data-piecolor-function="colorGt50">100</span> %
…
</body></code></pre>
<p> <span class="progresspie" data-piecolor-function="colorGt50">0</span> %
<span class="progresspie" data-piecolor-function="colorGt50">5</span> %
<span class="progresspie" data-piecolor-function="colorGt50">25</span> %
<span class="progresspie" data-piecolor-function="colorGt50">42</span> %
<span class="progresspie" data-piecolor-function="colorGt50">50</span> %
<span class="progresspie" data-piecolor-function="colorGt50">65</span> %
<span class="progresspie" data-piecolor-function="colorGt50">80</span> %
<span class="progresspie" data-piecolor-function="colorGt50">99</span> %
<span class="progresspie" data-piecolor-function="colorGt50">100</span> %</p>
<p>The same with class <code>progressring</code> instead of <code>progresspie</code>:</p>
<p> <span class="progressring" data-piecolor-function="colorGt50">0</span> %
<span class="progressring" data-piecolor-function="colorGt50">5</span> %
<span class="progressring" data-piecolor-function="colorGt50">25</span> %
<span class="progressring" data-piecolor-function="colorGt50">42</span> %
<span class="progressring" data-piecolor-function="colorGt50">50</span> %
<span class="progressring" data-piecolor-function="colorGt50">65</span> %
<span class="progressring" data-piecolor-function="colorGt50">80</span> %
<span class="progressring" data-piecolor-function="colorGt50">99</span> %
<span class="progressring" data-piecolor-function="colorGt50">100</span> %</p>
<h2>Percent value invisible in <code>data-percent</code>-attribute instead of element content</h2>
<pre><code class="language-html"><span class="progresspie red" data-percent="0"> some text</span>
<span class="progresspie red" data-percent="5"></span>
…</code></pre>
<p> <span class="progresspie" data-percent="0"> some text</span>
<span class="progresspie" data-percent="5"></span>
<span class="progresspie" data-percent="25"></span>
<span class="progresspie" data-percent="42"></span>
<span class="progresspie" data-percent="50"></span>
<span class="progresspie" data-percent="65"></span>
<span class="progresspie" data-percent="80"></span>
<span class="progresspie" data-percent="99"></span>
<span class="progresspie" data-percent="100"></span></p>
<p>The same with class <code>progressring</code> instead of <code>progresspie</code>:</p>
<p> <span class="progressring" data-percent="0"> some text</span>
<span class="progressring" data-percent="5"></span>
<span class="progressring" data-percent="25"></span>
<span class="progressring" data-percent="42"></span>
<span class="progressring" data-percent="50"></span>
<span class="progressring" data-percent="65"></span>
<span class="progressring" data-percent="80"></span>
<span class="progressring" data-percent="99"></span>
<span class="progressring" data-percent="100"></span></p>
<p>Notice the slightly different size: The first pie gets sized to fit the content "some text".
The others all get a default size because the empty span does not define a height the pie could adjust to.
(See plugin documentation for details on sizing.)</p>
<h2><a id="valueinput"></a>Take value from form input element</h2>
<p>Consider you're designing an HTML form for a user to fill, you might want to add a pie or ring chart visualizing the value of an input (like a text input or a select box). In that case, simply add the <code>data-input</code> attribute and fit it with a jQuery selector specifying the input element from which to read the value.
In the simplest form, if the input has an <code>id</code>, the selector is <code>#</code> followed by the input's <code>id</code> value:</p>
<pre><code class="language-html"><select id="valueSelect">
<option value="0">—</option>
<option value="20">20 %</option>
<option value="40">40 %</option>
<option value="60">60 %</option>
<option value="80">80 %</option>
<option value="100">100 %</option>
</select>
<span class="progresspie" data-input="#valueSelect"></span></code></pre>
<select id="valueSelect">
<option value="0">—</option>
<option value="20">20 %</option>
<option value="40">40 %</option>
<option value="60">60 %</option>
<option value="80">80 %</option>
<option value="100">100 %</option>
</select>
<span class="progresspie" data-input="#valueSelect"></span>
<pre><code class="language-html"><input id="valueInput" type="text" value="50" size="3">
<span class="progresspie" data-input="#valueInput"></span></code></pre>
<input id="valueInput" type="text" value="50" size="3">
<span class="progresspie" data-input="#valueInput"></span>
<h2>Updating</h2>
<pre><code class="language-html"><head>
…
<script type="text/javascript">
var timerVal = 0;
var timerRunning = false;
function startStopTimer() {
timerRunning = !timerRunning;
if (timerRunning) {
timer();
}
}
function timer() {
if (timerRunning) {
timerVal+= 1;
if (timerVal > 100) {
timerVal = 0;
}
$("#update1").text(timerVal);
$("#update2").text("%").attr("data-percent", timerVal);
progressPies.draw();
if (timerVal < 100)
window.setTimeout(timer, 400);
else
timerRunning = false;
}
}
</script>
</head>
…
<body>
…
<p><span id="update1" class="progresspie color">0</span> %<br>
<span id="update2" class="progressring color" data-percent="0">%</span><br>
<button onclick="timer()">Start / Stop</button>
</p>
…
</body></code></pre>
<p><span id="update1" class="progresspie color">0</span> %<br>
<span id="update2" class="progressring color" data-percent="0">%</span><br>
<button onclick="startStopTimer()">Start / Stop</button>
</p>
<h2>Default “Busy-Indicators”</h2>
<p>Add the class <code>busy</code> to <code>progresspie</code> or <code>progressring</code> in order
to render a “busy-indicator” not showing a percent value but displaying either a rotating pie slice
or a ring with a gap in order to indicate that your application is busy without any progress being measured.</p>
<p>See <a href="examples.html">examples.html</a> for more possible “busy-indicators” using the plug-in directly.
This simple “application” script provides only these two default graphics, yet they may be combined with
other classes or attributes as shown above, e.g. in order to define the color.</p>
<pre><code class="language-html"><span class="progresspie busy"></span>
<span class="progressring busy" data-piecolor="navy"></span></code></pre>
<p><span class="progresspie busy"></span>
<span class="progressring busy" data-piecolor="navy"></span></p>
</body>
</html>