A progress bar allows you to visually display the status of an ongoing process. Some common uses for progress bars are to display:
Progress is measured as a number between 0 and the target value that you set. The current progress status is referred to as the value of the progress bar. The area indicating the progress that has already been made is colored in the foreground color and the remaining area until the target value is colored in the background color.Â
The progress bar's API allows you to get or set the value and target value. You can also set the styling of the background color, foreground color, border color, and border width. To learn more, see ProgressBar in the API Reference.
To indicate progress in a progress bar, you change the progress bar's value in code. Sometimes you simply change the value to a new value. In other cases, you need to first calculate the new value before setting it.Â
Let's say you're using a progress bar to indicate how much of a profile a user has completed. After every step the user completes, you can change the progress bar's value to one more than the current value.Â
Let's say you're using a progress bar to show how much money has been raised. Typically, you need to calculate that value by running an aggregation on a database collection where you store individual contributions as items. Then, use the result of the aggregation to set the value in the progress bar.Â
You can do this on-the-fly when displaying the progress bar using only code. Or you can perform the aggregation each time a contribution has been made and store that value in a collection. Then, you can connect the progress bar to that stored value using a dataset.