Circular rainbow progress indicator

I recently attempted to incorporate the following progress bar into my React application:

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

Currently, I am using the code snippet below:

  var angleInRadians = (angleInDegrees-90) * Math.PI / 180.0;

  return {
    x: centerX + (radius * Math.cos(angleInRadians)),
    y: centerY + (radius * Math.sin(angleInRadians))
  };
}

function describeArc(x, y, radius, startAngle, endAngle){

    var start = polarToCartesian(x, y, radius, endAngle);
    var end = polarToCartesian(x, y, radius, startAngle);

    var largeArcFlag = endAngle - startAngle <= 180 ? "0" : "1";

    var d = [
        "M", start.x, start.y, 
        "A", radius, radius, 0, largeArcFlag, 0, end.x, end.y
    ].join(" ");

    return d;       
}

This code generates two SVG paths within each other, resulting in the structure shown here:

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

However, I am facing issues with the corners and need guidance on resolving this problem.

Here is how I am creating the rounded shapes:

<circle
                    cx={size / 2}
                    cy={size / 2}
                    r={
                        renderDoubleCircleProgress
                            ? size / 2 - 5 - 9
                            : size / 2 - 5
                    }
                    strokeWidth={
                        thickness
                    }
                    fill='none'
                    className={className}
                />
               
                    <circle
                        cx={size / 2}
                        cy={size / 2}
                        r={size / 2 - 5}
                        strokeWidth={
                            thickness
                        }
                        fill='none'
                        className={className}
                    />

Answer №1

If you want to achieve this effect, a radial gradient with the right specifications can do the trick - here's an example:

<svg width="800px" height="600px">
<defs>
      <radialGradient id="myGradient" gradientUnits="userSpaceOnUse" cx="250" cy="250" r="220">
      <stop offset="0%" stop-color="white" />
      <stop offset="90%" stop-color="green" />
      <stop offset="97.5%" stop-color="green" />
      <stop offset="98%" stop-color="cyan" />
    </radialGradient>
  </defs>

  <path stroke-width="40" d="M100 100 A 200 200 0 0 1 400 400" stroke="url(#myGradient)" fill="none" stroke-linecap="round"/>
  
  
</svg>

Answer №2

When working with more than 2 circles, it's important to ensure those rounded corners are present:

<script src="https://pie-meister.github.io/PieMeister-with-Progress.min.js"></script>

<progress-circle edge="grey">
  <style>
    svg {
      font: 16px arial;
      height: 220px;
    }
  </style>
  <progress value="75%" stroke="green">SEO</progress>
  <progress value="60%" stroke="orange">Social</progress>
  <progress value="65%" stroke="teal" edge="black">Maps</progress>
  <progress value="50%" stroke="orangered">Traffic</progress>
</progress-circle>

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

Ways to increase the spacing between content boxes using Bootstrap

I currently have a row of three Bootstrap boxes structured like this: <div class="row"> <div class="col-lg-4 pathBoxMain"> <h2>Content</h2> </div> <div class="col-lg-4 pathBoxMain"> <h2>Content</h2> </di ...

Changing the play state of the animation is causing synchronization issues with my audio

As I work on syncing a scroll effect animation in a div with an audio file, I've encountered an issue. The synchronization works perfectly when I set the element.style.animation property to 'none' when the audio is paused. However, things ge ...

How can one efficiently implement a recursive dynamic expanding navigation bar in Angular, and what is the best method to toggle its menu items effectively?

I am currently developing an Angular 8 app and utilizing a bootstrap 4 layout in my project. One of the features I am working on is a menu with nested items, inspired by the Dynamic Expanding Nav Drawer example. The challenge I am encountering is that whe ...

When scrolling, dynamically change the background color by adding a class

I am looking to achieve a scroll effect where the color of the menu buttons changes. Perhaps by adding a class when scrolling and hitting the element? Each menu button and corresponding div has a unique ID. Can anyone suggest what JavaScript code I should ...

When incorporating Bootstrap into my React code, it is essential to enclose adjacent JSX elements within a wrapping tag

Line 15:1: Error detected while parsing: Adjacent JSX elements must be surrounded by a parent tag. If you intended to use a JSX fragment <>...</>, please do so. 13 | //crossorigin></script> 14 | > 15 | < ...

Combine less files in webpack to generate a single minified CSS output file

Can webpack be used to combine multiple less files into one minified CSS file? I'm having trouble setting different output paths for my files. How can I make my CSS file output to './assets/stylesheets/bundle/' instead of './assets/ja ...

What is the best way to ensure bootstrap cards' container expands horizontally?

Currently experimenting with Bootstrap 4 cards (view more at ) My goal is to have a container with a card deck inside that stretches horizontally as I add new cards, causing a horizontal scrollbar to appear when needed. By default, when the container wid ...

Utilize various CSS styles for text wrapping

I'm struggling to figure out where to begin with this problem. My goal is to create a three-column row that can wrap below each other if they cannot fit horizontally. The height of the row should adjust to accommodate the items while maintaining a fix ...

The float right attribute doesn't stay contained within the box; instead, it drifts outside the box

I've been struggling to keep this box fixed at the top of the browser, but I'm facing an issue with the positioning on the right side. I can't seem to figure out how to solve it, so I'm reaching out for some help. #StickyBar #RightSide ...

Utilizing a loaded variable containing data from an external API request within the useEffect() hook of a React component

Essentially, I have an API request within the useEffect() hook to fetch all "notebooks" before the page renders, allowing me to display them. useEffect(() => { getIdToken().then((idToken) => { const data = getAllNotebooks(idToken); ...

blade template does not reflect recent changes

I recently started working with Laravel and React, but I've run into some issues with my JS files. I tried renaming "Example" to "Examplee" in app.js, but the changes are not reflecting in the browser even in incognito mode. I've attempted clear ...

Is there a way for me to utilize the chosen value from the dropdown in order to make an API call with it and display the resulting JSON data

I need to implement a dropdown menu with 3-4 options. Once a user selects an option, I should make an API call using the selected value as the search parameter. The JSON response from the API call should be displayed in a DataGrid within the mainContent ar ...

Creating a stylish switch button with Html and CSS

I came across a fantastic tool for creating CSS buttons . I have created a switch button and I know that I need to run two JS codes - one for when the switch is on (alert("on")) and another for when it's off (alert("off")). Could you please assist me ...

Display a button with an icon only when in responsive mode using HTML, CSS, and Materialize

Is there a way to hide the text on a button but keep the icon visible when viewing on a mobile device? For instance, if a button displays a face icon from MaterializeCSS along with the text "support", I would like to eliminate the text while still showing ...

The automatic CSS cookie bar functions smoothly, but could benefit from a small delay

I successfully added a pure CSS cookie bar to my website, but there is a slight issue. When entering the site, the cookie bar is the first thing that appears, and then it goes up and down before settling at the end. How can I make my cookie bar only go do ...

The ProviderFunction module is refusing to export my newly created functions

Issue Description: I have created a FirebaseProvider function to supply all functions across my app within an object. However, I am facing an issue where all functions are being provided except for the most recent one: fetchTest. Explanation: When I click ...

Title padding extends beyond the boundaries of the div container

I have encountered an issue with the padding of the title being outside the div. To see the problem, check out my jsfiddle: http://jsfiddle.net/h8Guf/ <!-- HTML --> <div> <h2><a href="#">This is a test text</a></h2> ...

Is there a way for me to smoothly navigate to the top of the page after I click on the pagination button?

Once I set up a pagination feature, my goal was to have the page automatically scroll to the top whenever I clicked on the pagination buttons. I attempted to achieve this by using onChange={handleChange} and running pageTopRef.current.scrollIntoView({ beh ...

Tips for implementing input validation and dynamically enabling/disabling the submit button based on the form's state in ReactJS

I'm currently working with npm Validator to validate input information and dynamically change the state of the submit address button based on the validation. The issue I'm facing is that although I can see the entered text in the console, it does ...

Creating a mockup for a website design project in my class, utilizing HTML and CSS. Encountering issues with the CSS not displaying correctly, unsure of the root cause of the problem

Check out this wireframe design I created: https://i.stack.imgur.com/Ro3dl.png I'm working on translating this into HTML and CSS so that I can further develop it. The HTML Code: <!doctype html> <html> <head> <title> Trinit ...