|
| 1 | +--- |
| 2 | +title: Getting Started |
| 3 | +page_title: jQuery CircularProgressBar Documentation - Getting Started with the CircularProgressBar |
| 4 | +description: "Get started with the jQuery CircularProgressBar by Kendo UI and learn how to create, initialize, and enable the component." |
| 5 | +slug: getting_started_kendoui_circularprogressbar_widget |
| 6 | +position: 2 |
| 7 | +--- |
| 8 | + |
| 9 | +# Getting Started with the CircularProgressBar |
| 10 | + |
| 11 | +This guide demonstrates how to get up and running with the Kendo UI for jQuery CircularProgressBar. |
| 12 | + |
| 13 | +After the completion of this guide, you will be able to achieve the following end result: |
| 14 | + |
| 15 | +```dojo |
| 16 | +<div id="circularprogressbar"></div> |
| 17 | +
|
| 18 | +<script> |
| 19 | + $("#circularprogressbar").kendoCircularProgressBar({ |
| 20 | + value: 10, // Change the value to see the difference between the colors. |
| 21 | + colors: [{ |
| 22 | + to: 25, |
| 23 | + color: '#C0392B' |
| 24 | + }, { |
| 25 | + from: 25, |
| 26 | + to: 50, |
| 27 | + color: '#D35400' |
| 28 | + }, { |
| 29 | + from: 50, |
| 30 | + to: 75, |
| 31 | + color: '#D4AC0D' |
| 32 | + }, { |
| 33 | + from: 75, |
| 34 | + to: 99, |
| 35 | + color: '#58D68D' |
| 36 | + }, { |
| 37 | + from: 99, |
| 38 | + color: '#229954' |
| 39 | + }], |
| 40 | + centerTemplate: '<span style="color: #: color #;">#= value == 100 ? "<span class=\'k-icon k-i-check\'></span>" : value + "%" #</span>' |
| 41 | + }); |
| 42 | +
|
| 43 | + let interval = setInterval(function () { |
| 44 | + let pb = $("#circularprogressbar").data("kendoCircularProgressBar"); |
| 45 | + let value = pb.value(); |
| 46 | + if (value >= 100) { |
| 47 | + clearInterval(interval); |
| 48 | + return; |
| 49 | + } |
| 50 | + pb.value(value + 1); |
| 51 | + }, 50); |
| 52 | +</script> |
| 53 | +``` |
| 54 | + |
| 55 | +## 1. Create a Div Element |
| 56 | + |
| 57 | +First, create an empty `<div>` element on the page and use it as an initialization element for the CircularProgressBar. |
| 58 | + |
| 59 | +```html |
| 60 | + <div id="circularprogressbar"></div> |
| 61 | +``` |
| 62 | + |
| 63 | +## 2. Initialize the CircularProgressBar |
| 64 | + |
| 65 | +In this step, you will initialize the CircularProgressBar from the `<div>` element. When you initialize the component, all settings of the CircularProgressBar will be provided in the script statement. You have to describe its configuration and event handlers in JavaScript. |
| 66 | + |
| 67 | +```html |
| 68 | + <div id="circularprogressbar"></div> |
| 69 | + |
| 70 | + <script> |
| 71 | + // Target the div element by using jQuery and then call the kendoCircularProgressBar() method. |
| 72 | + $("#circularprogressbar").kendoCircularProgressBar(); |
| 73 | + </script> |
| 74 | +``` |
| 75 | + |
| 76 | +## 3. Set the Value |
| 77 | + |
| 78 | +After the initialization, you can set the value of the component by using the [`value`](/api/javascript/ui/circularprogressbar/configuration/value) option. |
| 79 | + |
| 80 | +```html |
| 81 | + <div id="circularprogressbar"></div> |
| 82 | + |
| 83 | +<script> |
| 84 | + $("#circularprogressbar").kendoCircularProgressBar({ |
| 85 | + value: 10 |
| 86 | + }) |
| 87 | +</script> |
| 88 | +``` |
| 89 | + |
| 90 | +## 4. Set the Colors Option |
| 91 | + |
| 92 | +Using the [`colors`](/api/javascript/ui/circularprogressbar/configuration/colors) option, you can change the color of the CircularProgressBar line based on the current value. |
| 93 | + |
| 94 | +```html |
| 95 | + <div id="circularprogressbar"></div> |
| 96 | + |
| 97 | +<script> |
| 98 | + $("#circularprogressbar").kendoCircularProgressBar({ |
| 99 | + value: 10, // Change the value to see the difference between the colors. |
| 100 | + colors: [{ |
| 101 | + to: 25, |
| 102 | + color: '#C0392B' |
| 103 | + }, { |
| 104 | + from: 25, |
| 105 | + to: 50, |
| 106 | + color: '#D35400' |
| 107 | + }, { |
| 108 | + from: 50, |
| 109 | + to: 75, |
| 110 | + color: '#D4AC0D' |
| 111 | + }, { |
| 112 | + from: 75, |
| 113 | + to: 99, |
| 114 | + color: '#58D68D' |
| 115 | + }, { |
| 116 | + from: 99, |
| 117 | + color: '#229954' |
| 118 | + }] |
| 119 | + }); |
| 120 | +</script> |
| 121 | +``` |
| 122 | + |
| 123 | +## 5. Set a Center Template |
| 124 | + |
| 125 | +You can specify how the center of the CircularProgressBar will appear using a template. |
| 126 | + |
| 127 | +```html |
| 128 | +<div id="circularprogressbar"></div> |
| 129 | + |
| 130 | +<script> |
| 131 | + $("#circularprogressbar").kendoCircularProgressBar({ |
| 132 | + value: 10, // Change the value to see the difference between the colors. |
| 133 | + colors: [{ |
| 134 | + to: 25, |
| 135 | + color: '#C0392B' |
| 136 | + }, { |
| 137 | + from: 25, |
| 138 | + to: 50, |
| 139 | + color: '#D35400' |
| 140 | + }, { |
| 141 | + from: 50, |
| 142 | + to: 75, |
| 143 | + color: '#D4AC0D' |
| 144 | + }, { |
| 145 | + from: 75, |
| 146 | + to: 99, |
| 147 | + color: '#58D68D' |
| 148 | + }, { |
| 149 | + from: 99, |
| 150 | + color: '#229954' |
| 151 | + }], |
| 152 | + centerTemplate: '<span style="color: #: color #;">#= value == 100 ? "<span class=\'k-icon k-i-check\'></span>" : value + "%" #</span>' |
| 153 | + }); |
| 154 | +
|
| 155 | + let interval = setInterval(function () { |
| 156 | + let pb = $("#circularprogressbar").data("kendoCircularProgressBar"); |
| 157 | + let value = pb.value(); |
| 158 | + if (value >= 100) { |
| 159 | + clearInterval(interval); |
| 160 | + return; |
| 161 | + } |
| 162 | + pb.value(value + 1); |
| 163 | + }, 50); |
| 164 | +</script> |
| 165 | +``` |
| 166 | + |
| 167 | +## Next Steps |
| 168 | + |
| 169 | +* [Referencing Existing Component Instances]({% slug widget_methodsand_events_kendoui_installation %}) |
| 170 | +* [Colors of the CircularProgressBar]({% slug colors_kendoui_circularprogressbar_widget %}) |
| 171 | + |
| 172 | +## See Also |
| 173 | + |
| 174 | +* [Indeterminate CircularProgressBar (Demo)](https://demos.telerik.com/kendo-ui/circularprogressbar/indeterminate) |
| 175 | +* [JavaScript API Reference of the CircularProgressBar](/api/javascript/ui/circularprogressbar) |
| 176 | +* [Knowledge Base Section](/knowledge-base) |
| 177 | + |
| 178 | +<script> |
| 179 | + window.onload = function() { |
| 180 | + document.getElementsByClassName("btn-run")[0].click(); |
| 181 | + } |
| 182 | +</script> |
0 commit comments