Creating a unique-looking visual representation of progress with arcs

Looking to create a circular progress bar (see image below), with loading starting from the left bottom side up to the right bottom side. The empty state should be light-blue (#E8F6FD) and the progress color strong blue (#1CADEB).

https://i.sstatic.net/VZ9Lg.png

I've experimented with a few approaches, but haven't found the ideal solution for this implementation:

  1. Initially, I tried using a div element with styles like border-radius: 50%; and
    border-bottom-color: transparent;
    , here's a jsfiddle. While I achieved the desired shape, I struggled with how to fill the border with progress.
  2. My second attempt involved using canvas, which worked well except that the loader only appeared after all JS was loaded. I wanted to avoid this delay and have the loader display immediately when the page loads, jsfiddle.

Are there any alternative methods to create an arc loader or suggestions to overcome the challenges mentioned above?

Answer â„–1

If you want to create an arc shape, consider using inline SVG with arc commands. To animate the arc, you can utilize CSS to transition the stroke-dasharray property.

Check out this example where hovering over the arc triggers a loading animation:

svg {
  display: block;
  width: 40%;
  margin: 0 auto;
}
.loader {
  stroke-dasharray: .5 18 19;
  transition: stroke-dasharray 2s linear;
}
svg:hover .loader {
  stroke-dasharray: 19 0 19;
}
<svg viewbox="0 0.5 10 8">
  <path d="M2 8 A 4 4 0 1 1 8 8" fill="none" stroke-width="0.78" stroke="#E8F6FD" />
  <path class="loader" d="M2 8 A 4 4 0 1 1 8 8" fill="none" stroke-width="0.8" stroke="#00ACEE" />
</svg>

Remember to include vendor prefixes for the transition property to ensure browser compatibility (more details on canIuse).

Answer â„–2

Unique SVG Animation

Check out this innovative circle animation created using only SVG and CSS.
It took quite some time to perfect the timings and effects, resulting in a visually captivating loading animation.

body {
  background-color: #222;
}
.load {
  fill: none;
  stroke: #e8f6fd;
  stroke-width: 5;
  stroke-dasharray: 200 300;
  transform: rotate(142deg);
  transform-origin: 50px 50px;
  animation: progress 5s linear reverse;
}
@keyframes progress {
  from {
    stroke-dasharray: 200 300;
  }
  to {
    stroke-dasharray: 0 300;
  }
}
.spesial {
  stroke: #1cadeb;
  stroke-dasharray: 5 300;
  transform: rotate(30deg);
  animation: circpro 5s linear;
}
@keyframes circpro {
  from {
    transform: rotate(-220deg);
  }
  to {
    transform: rotate(30deg);
  }
}
<svg viewBox="0 0 100 100" width="200px">
  <circle class="load" cx="50" cy="50" r="45" />
  <circle class="load spesial" cx="50" cy="50" r="45" />
</svg>

Answer â„–3

Presenting a Solution Using HTML, CSS, and JS:

The key aspect of this implementation relies on utilizing conic-gradient() in CSS. For more details, you can explore the following resources: MDN Documentation on Conic Gradient. It is also essential to understand how absolute positioning functions. Refer to the code snippet below for the solution.

Check out the Demo: https://i.sstatic.net/B8OvX.gif

Additional Information: If you are interested in creating a dynamic and customizable progress meter through a reusable component, feel free to take a look at my Angular-based solution available in the demo below.

Explore the Demo: https://i.sstatic.net/AgqmV.gif

Access the Source Code Link (CodeSandbox): https://codesandbox.io/p/sandbox/progress-me-6s9cxm

function delay(ms) {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

function handleOnStartProgressMeterClick() {
  let testMeterPercentage = 0;
  const outerCircle = document.getElementById("outer-circle");
  
  // mock delay
  (async() => {
    while (testMeterPercentage <= 75) {
    
      outerCircle.style.setProperty('background-image', 'conic-gradient(' +
        '#00acee' +
        ' ' +
        ((360 / 100) * testMeterPercentage) +
        'deg, ' + '#e8f6fd' +
        ' ' +
        ((360 / 100) * testMeterPercentage) +
        'deg 270deg, ' + 'white 270deg 360deg)'

      );
      testMeterPercentage++;
      await delay(30);
    }
  })();

}
.outer-circle {
  position: relative;
  height: 100px;
  width: 100px;
  border-radius: 100%;
  transform: rotate(225deg);
}

.inner-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  height: calc(100% - (10px * 2));
  width: calc(100% - (10px * 2));
  transform: translateX(-50%) translateY(-50%);
  border-radius: 100%;
  background: white;
}
<div class="outer-circle" id="outer-circle">
  <div class="inner-circle" id="inner-circle">
  </div>
</div>
<button onclick="handleOnStartProgressMeterClick()">Start Progress Meter</button>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error: The request to /api/auth/login in Postman failed unexpectedly

As I am working on developing an app using node.js and express, I encountered an error while making post requests in Postman. Cannot POST /api/auth/login%0A Below are the details of my app's structure along with the files involved: app.js const ex ...

How can you incorporate a value into a variable in PHP?

Hey there! I'm pretty new to PHP and I've been working on building a program that resembles a spreadsheet. My form consists of columns and cells, allowing users to add or delete rows using Javascript. The challenge I'm facing is automating t ...

Rendering HTML or links sourced from encoded JSON data with JavaScript

After making an ajax call, I receive the following data: {"dataList":[{"date":"August 27, 2013","text":"<a href=\"http:\/\/www.example.com\/test.aif\" title=\"Click here to listen\" target=\"\">Click her ...

My goal is to exclusively create illustrations of items within a camera's view

Currently, I am using THREEJS to create a dynamically generated 'minecraft' world utilizing a perlin noise generator. Check out the progress so far: Block World Everything is going smoothly except that I am facing significant performance issues ...

React is unable to identify the `InputProps` prop when applied to a DOM element

https://i.sstatic.net/7fZmn.png Caution: React is not able to identify the InputProps property on a DOM element. If you intend for it to be displayed in the DOM as a custom attribute, spell it in lowercase as inputprops. If you accidentally passed it from ...

Converting an unbroken series of string values into organized key-value pairs for easy reference

I assure you this is not a duplicated question. Despite my attempts with JSON.parse(), it seems to be ineffective. Here's the issue at hand: I recently received assistance from an answer that was both crucial and enlightening. However, the code prov ...

Angular/JS encountered a premature end of program unexpectedly

I am taking my first steps in the world of web development with Angular (and JavaScript in general). I have been trying to rewrite some basic and common examples using Angular. One thing I attempted was to display a simple message using data binding. This ...

Container slide-show fill error

I'm attempting to create a slide show with an overlapping caption that appears when hovering over the container or image. The image needs to fit exactly inside the container so no scroll bar is shown and the border radius is correct. I managed to achi ...

Filtering dynamically generated table rows using Jquery

I'm currently working on a project that involves filtering a dynamic table based on user input in a search bar. The table contains information such as name, surname, phone, and address of users. Using jQuery, I have created a form that dynamically ad ...

Discovering the keycode for the GO button in JavascriptDiscovering the keycode

Can anyone help me figure out how to find the keycode for the GO button using Javascript in an Android browser? ...

Encountering an 'Unknown provider' error while running a unit test with AngularJS and Jasmine

I am facing an issue while writing a unit test for a controller in my application. Jasmine is showing an 'Unknown provider' error related to a provider I created for fetching template URLs. This provider is injected into a config function that is ...

Is it possible to pass an AngularJS ng-form object as a parameter in ng-if?

When I try to preview, the save button in my preview mode remains enabled. You can view the code snippet here: http://plnkr.co/edit/I3n29LHP2Yotiw8vkW0i I believe this issue arises because the form object (testAddForm) is not accessible within the ng-if s ...

Filtering data with React's multiselect checkboxes

I have created an amazing app that fetches a list of todos from this incredible source To enhance user experience, I developed a special CheckBoxDropDown component for selecting todo IDs Within the CheckBoxDropDown.js component, I am passing the onChange ...

Real-time preview of a text field in JavaScript

I'm attempting to create a similar piece of code like the one at the bottom of this page for leaving comments. I have the basic code, but the result doesn't display new lines (or HTML, although that's not essential). I have the function belo ...

Is there a more efficient approach to applying a basic function to multiple elements within a DIV and having it activate only upon a click event using jQuery?

This solution works, but I am looking for a more professional approach in order to adhere to the principle of "don't repeat yourself." $("document").ready(function(){ $(".child").each(function(index){ $(this).click(func ...

I am currently working with an input element that is set to hidden. I am trying to change its type to text using JavaScript, but I can't seem to figure out how to do it or if it is even possible

I'm stuck trying to change the type of an input element from hidden to text using JavaScript. I can't seem to figure out if it's even possible. Can someone please help me with this? Thanks! ...

Error 422 encountered while trying to create a new asset using the Contentful Content Management API

My attempt to create and publish an image as an asset using the Contentful Content Management API has hit a roadblock. I managed to successfully create and publish an entry, but I can't seem to figure out why creating an asset is not working as expect ...

Enhancing Function Calls for Better Performance in V8

Is V8 capable of optimizing repeated function calls with identical arguments? For instance, in the code snippet below, Variance is invoked twice with the same arguments. var Variance = require('variance'); function summary(items) { ...

How can I find the last element that was selected using XPath in the browser console

Need help with XPath: $x(("//div[@class='ag-header-row']))[1] I'm working with an array of divs, but I want to select the last one. The [1] is necessary due to multiple rows with this class. I’ve heard about using [last()], but unsure w ...

Exploring Highcharts Pie Chart with AJAX for Real-time Data Updates

Looking for some guidance with implementing AJAX in my code to make my chart dynamic based on data from the database. Although the code is error-free, the chart is not refreshing automatically. Any help, comments, or suggestions would be greatly appreciate ...