forked from olton/metroui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdonut.html
More file actions
307 lines (279 loc) · 13.8 KB
/
Copy pathdonut.html
File metadata and controls
307 lines (279 loc) · 13.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="twitter:site" content="@metroui">
<meta name="twitter:creator" content="@pimenov_sergey">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Metro 4 Components Library">
<meta name="twitter:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins built on jQuery.">
<meta name="twitter:image" content="https://metroui.org.ua/images/m4-logo-social.png">
<meta property="og:url" content="https://metroui.org.ua/v4/index.html">
<meta property="og:title" content="Metro 4 Components Library">
<meta property="og:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins built on jQuery.">
<meta property="og:type" content="website">
<meta property="og:image" content="https://metroui.org.ua/images/m4-logo-social.png">
<meta property="og:image:secure_url" content="https://metroui.org.ua/images/m4-logo-social.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="968">
<meta property="og:image:height" content="504">
<meta name="author" content="Sergey Pimenov">
<meta name="description" content="Need progress bar in the form of a donut? Use donut component to create it. The most popular HTML, CSS, and JS library in Metro style.">
<meta name="keywords" content="HTML, CSS, JS, Metro, CSS3, Javascript, HTML5, UI, Library, Web, Development, Framework">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link href="metro/css/metro-all.css?ver=@@b-version" rel="stylesheet">
<link href="highlight/styles/github.css" rel="stylesheet">
<link href="docsearch/docsearch.min.css" rel="stylesheet">
<link href="css/site.css" rel="stylesheet">
<title>Donut - Metro 4 :: Popular HTML, CSS and JS library</title>
</head>
<body>
<div class="container-fluid">
<div class="row flex-xl-nowrap">
<div class="cell-md-3 cell-xl-2 pr-0 border-right bd-light" id="sidenav">
</div>
<div class="d-none d-block-xl cell-xl-2 order-2 border-left bd-light toc-wrapper">
<h5>Table of contents</h5>
<hr/>
<ul class="toc-nav">
<li class="toc-entry"><a href="#">Donut</a></li>
<li class="toc-entry"><a href="#_donut_create">Create donut</a></li>
<li class="toc-entry"><a href="#_donut_value">Set & get value</a></li>
<li class="toc-entry"><a href="#_donut_options">Options</a></li>
<li class="toc-entry"><a href="#_donut_events">Events</a></li>
</ul>
</div>
<main class="cell-md-9 cell-xl-8 order-1 pr-1-sx pl-1-sx pr-5-md pl-5-md">
<div class="place-right d-none d-block-lg" style="width: 200px;">
<img src="images/logo.png" class="w-100">
</div>
<h1>Donut</h1>
<p class="text-leader">
Need progress bar in the form of a donut? Use donut component to create it.
</p>
<!-- ads-html -->
<h3 id="_donut_create">Create donut</h3>
<p>
To create progress bar in the form of a donut add <code>data-role="donut"</code> to element. To set <code>value</code> use attribute <code>data-value="..."</code>.
</p>
<div class="example">
<div class="row">
<div class="cell-md-3">
<div class="mx-auto" id="donut1" data-role="donut" data-value="35" data-show-value="true" data-cap=""></div>
</div>
<div class="cell-md-3">
<div class="mx-auto" id="donut2" data-role="donut" data-value="35" data-hole="0" data-stroke="transparent" data-fill="#4CAF50" data-animate="10"></div>
</div>
<div class="cell-md-3">
<div class="mx-auto" id="donut3" data-role="donut" data-value="35" data-hole=".6" data-stroke="#f5f5f5" data-fill="#9C27B0" data-animate="10"></div>
</div>
<div class="cell-md-3">
<div class="mx-auto" id="donut4" data-role="donut" data-value="35" data-stroke="#F44336" data-fill="#FFC107" data-color="#FFFFFf" data-cap="" data-animate="10" data-background="#4fc3f7" data-font-size="32"></div>
</div>
</div>
</div>
<pre><code>
<div id="donut1" data-role="donut" data-value="35"></div>
<div id="donut2" data-role="donut" data-value="35"
data-hole="0" data-stroke="transparent"
data-fill="#4CAF50" data-animate="10"></div>
<div id="donut3" data-role="donut" data-value="35"
data-hole=".6" data-stroke="#f5f5f5" data-fill="#9C27B0"
data-animate="10"></div>
<div id="donut4" data-role="donut" data-value="35"
data-stroke="#F44336" data-fill="#FFC107" data-color="#FFFFFf"
data-cap="" data-animate="10" data-background="#4fc3f7"
data-font-size="32"></div>
</code></pre>
<h3 id="_donut_value">Set and get value</h3>
<p>
To set or get <code>value</code> you can use component method <code>val()</code>. Also you can set value at runtime with attribute <code>data-value</code>.
</p>
<div class="example">
<div id="donut_val" data-role="donut" data-value="35" class="mx-auto"></div>
<br>
<button class="button" onclick="setDonutNewValue()">Set new value</button>
<button class="button" onclick="getDonutValue()">Get value</button>
</div>
<pre><code>
<div id="donut_val" data-role="donut" data-value="35" class="mx-auto"></div>
<button class="button" onclick="setDonutNewValue()">Set new value</button>
<button class="button" onclick="getDonutValue()">Get value</button>
<script>
function setDonutNewValue(){
var donut = $('#donut_val').data('donut');
donut.val(Metro.utils.random(0, 100));
}
function getDonutValue(){
var donut = $('#donut_val').data('donut');
alert(donut.val());
}
</script>
</code></pre>
<h3 id="_donut_options">Options</h3>
<p>
Donut component has a number of options. You can use that options to set style and behavior of component.
</p>
<table class="table cell-border table-border options-table">
<thead>
<tr>
<th>Options</th>
<th>Data-*</th>
<th>Default</th>
<th>Desc</th>
</tr>
</thead>
<tbody>
<tr>
<td>size</td>
<td>data-size</td>
<td>100</td>
<td>The width of component</td>
</tr>
<tr>
<td>radius</td>
<td>data-radius</td>
<td>50</td>
<td>The radius of donut</td>
</tr>
<tr>
<td>hole</td>
<td>data-hole</td>
<td>.8</td>
<td>The hole size (from 0 to 1)</td>
</tr>
<tr>
<td>value</td>
<td>data-value</td>
<td>0</td>
<td>The donut value</td>
</tr>
<tr>
<td>background</td>
<td>data-background</td>
<td>#ffffff</td>
<td>The donut background color</td>
</tr>
<tr>
<td>color</td>
<td>data-color</td>
<td>#000000</td>
<td>The donut text color</td>
</tr>
<tr>
<td>stroke</td>
<td>data-stroke</td>
<td>#d1d8e7</td>
<td>The donut value stroke color</td>
</tr>
<tr>
<td>fill</td>
<td>data-fill</td>
<td>#49649f</td>
<td>The donut value background color</td>
</tr>
<tr>
<td>fontSize</td>
<td>data-font-size</td>
<td>24</td>
<td>The donut text font size (in px)</td>
</tr>
<tr>
<td>total</td>
<td>data-total</td>
<td>100</td>
<td>The maximum of donut value</td>
</tr>
<tr>
<td>cap</td>
<td>data-cap</td>
<td>%</td>
<td>Additional caption for donut text</td>
</tr>
<tr>
<td>animate</td>
<td>data-animate</td>
<td>0</td>
<td>Animation factor (from 0 to 10)</td>
</tr>
<tr>
<td>showValue</td>
<td>data-show-value</td>
<td>false</td>
<td>if true, value is displayed, false - display percent </td>
</tr>
</tbody>
</table>
<h3 id="_donut_events">Events</h3>
<p>
When donut works, it generated the numbers of events. You can use callback for this event to behavior with donut.
Rules for working with events are described on <a href="events.html">this page</a>.
</p>
<table class="table cell-border table-border options-table">
<thead>
<tr>
<th>Event</th>
<th>Data-*</th>
<th>Default</th>
<th>Desc</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>onChange(val, el)</code></td>
<td><code>data-on-change</code></td>
<td>Metro.noop</td>
<td>Callback for value change</td>
</tr>
<tr>
<td><code>onDonutCreate(el)</code></td>
<td><code>data-on-donut-create</code></td>
<td>Metro.noop</td>
<td>Callback fired when donut is created</td>
</tr>
</tbody>
</table>
<pre><code>
<div data-role="donut"
data-value="35"
data-on-donut-create="console.log('Donut was created!')"
data-on-change="console.log(arguments)"
></div>
</code></pre>
</main>
</div>
</div>
<script src="docsearch/docsearch.min.js"></script>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="metro/js/metro.js?ver=@@b-version"></script>
<script src="highlight/highlight.pack.js"></script>
<script src="js/clipboard.min.js"></script>
<script src="js/site.js"></script>
<script>
var donut_interval = null;
(function(){
clearInterval(donut_interval);
donut_interval = setInterval(function(){
var i, d;
for (i = 0; i < 4; i++) {
d = Metro.utils.random(0,100);
$('#donut'+(i+1)).data('donut').val(d);
}
}, 2000);
})();
function setDonutNewValue(){
var donut = $('#donut_val').data('donut');
donut.val(Metro.utils.random(0, 100));
}
function getDonutValue(){
var donut = $('#donut_val').data('donut');
alert(donut.val());
}
</script>
<!-- ads-script -->
<!-- ga-script -->
<!-- hit-ua -->
</body>
</html>