Several radial progress charts in JavaScript

While attempting to recreate and update this chart, I successfully created a separate chart but encountered difficulties with achieving the second progress.

The secondary chart

<div id="radial-progress-vha">
            <div class="circle-vha">
            <div class="mask-vha full-vha">
            <div class="fill-vha"></div>
            </div>
            <div class="mask-vha half-vha">
            <div class="fill-vha"></div>
            <div class="fill-vha fix-vha"></div>
            </div>
            <div class="shadow-vha"></div>
            </div>
            <div class="inset-vha">
            <div class="percentage-vha">22.17</div>
            </div>
       </div>

Realizing that each graph should be unique, I duplicated the original CSS with different names. This is where things started to fall apart.

The JavaScript code

var transform_styles = ['-webkit-transform', '-ms-transform', 'transform'];
window.randomize = function() {
var rotation = Math.floor((180)*.123);
var fix_rotation = rotation;
for(i in transform_styles) {
    $('.circle .fill, .circle .mask.full').css(transform_styles[i],'rotate(' + rotation + 'deg)');
//$('.circle .mask.left').css(transform_styles[i], 'rotate(' + rotation + 'deg)');
$('.circle .fill.fix').css(transform_styles[i],'rotate(' + fix_rotation + 'deg)');
}
}
setTimeout(window.randomize, 200);
$('#radial-progress-vha');

Answer №1

I was able to solve the issue with a functional fiddle: http://jsfiddle.net/uouxcLbd/

The key problems that needed addressing included:

  • Eliminating the redundant definition of transform-styles
  • Removing unnecessary lines like $('#radial-progress-va'); and $('#radial-progress-vha');
  • Changing the name of the second instance of window.randomize
  • Adapting the second randomize function to work with css classes incorporating the -vha suffix
  • Correcting a typo in the CSS which caused the .fill-vha selector to malfunction due to a missing period

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

The Three.js camera imported from Collada is unable to properly focus on an object within the scene

Having some trouble grasping the concept of Collada Animation in Three.js! I have an animation with a moving camera in 3Dsmax, and exported the scene into Collada. loader.load( ColladaName, function ( collada ) { model = collada.scene; model.upda ...

Retrieving information through a jQuery ajax call

I've been working on creating an AJAX filter for a car list, but I've hit a roadblock in the final stage. My setup involves two files: index.php and filter.php. Within index.php, I have a form with dropdown lists and sliders. Here's the cod ...

How can I locate an element within the body of an if statement?

I am working on a simple JavaScript (jQuery library) if statement to check for the presence of a div element with the class 'video' on the page. If it finds the element, the variable 'arrows' is set to true, otherwise it is set to false ...

the overflow issue with Summernote's dropdown menu

I am currently working on a 2 columns layout within 2 divs that have different margins set. In the left column, I have integrated a bootstrap datetimepicker and summernote. While the datetimepicker dialog overflows outside the internal div, I am wondering ...

Conceal the content within the body and reveal a uniquely crafted div element using Print CSS

I came across numerous resources on using CSS to hide specific parts of a webpage. However, I am not looking to hide multiple divs like this: #flash,#menu,#anuncios { display:none; } Instead, my goal is to hide the entire body of the page and only displ ...

Is there a way for me to acquire the Amazon Fire TV Series?

I'm currently working on developing a web app for Amazon Fire TV, and I require individual authorization for each app. My plan is to utilize the Amazon Fire TV serial number for this purpose. However, I am unsure how to retrieve this serial using Jav ...

Is the stylesheet connected but failing to load?

Updating an app from Rails 3.2 to version 4 has been mostly successful, but I am encountering issues with some of my stylesheets not being applied correctly. Checking the source code (ctr+U), everything appears to be linked properly: <!DOCTYPE html> ...

How to receive multiple results in a jQuery AJAX request

I'm currently working on a jQuery post function that triggers a response upon a successful click on a div. The issue I'm facing is that I want to return multiple variables on success. Do I need to utilize JSON for this purpose, and if so, how can ...

Utilize jQuery ajax to handle form and URL processing via a GET request

When it comes to processing forms, I want to use the jQuery $.ajax GET method so that the query parameters are included in the URL. If I handle the form without using jQuery, achieving this is not a problem. However, when I utilize jQuery's $.ajax met ...

Utilizing JavaScript Plugin to Fix Image Source URLs in Incorrect Directories

I'm struggling and really in need of some assistance. The issue I'm facing is with a plugin that has a JavaScript file containing an array of URLs pointing to a "texture" directory within the plugin for images. However, I keep encountering 404 e ...

How can JavaScriptExecutor be used to stop searching for an element on a constantly scrolling interface, such as Facebook, after a specific time period?

Imagine that I am trying to locate my post on a Facebook page by continuously scrolling down. Specifically, I am searching for my post based on my profile name. To achieve this, I utilize JavascriptExecutor to initiate the scrolling process until it locate ...

Trouble with updating setText() and setProgress() functions within a ViewPager

My application employs a ViewPager along with Fragments. Each Fragment showcases a ListView containing multiple CheckBoxes, a ProgressBar, and a TextView. The requirement is that when 3 out of the 6 CheckBoxes are checked, the ProgressBar and TextView sh ...

Show the template when the link is clicked using Angular directive

Perhaps the question is not phrased properly, but here is the idea I am working on. I have a navbar set up with an array of countries that includes their names and coordinates. <body> <nav class="navbar navbar-default"> <div cl ...

What is the best way to position an image alongside text using Vue and Buefy?

I'm looking to add an image next to my text in Vue using Buefy. Take a look at the code I have so far, can someone offer some guidance? <template> <section class="hero is-link is-fullheight-with-navbar"> <div cla ...

Editing content directly within an ASP.NET Core MVC application through AJAX encounters a 400 error, indicating a Bad Request

I'm attempting to implement inline editing using AJAX in ASP.NET Core MVC, but I keep receiving a 400 error (Bad Request). The idea is to click on a table row to edit and save the new values in an SQL database. Could someone confirm if I am on the r ...

The sorting feature is not performing as anticipated

I'm dealing with an array of objects fetched from the backend. When mapping and sorting the data in ascending and descending order upon clicking a button, I encountered some issues with the onSort function. The problem lies in the handling of uppercas ...

What is the best way to send data to PHP while moving objects between different div elements?

I have a situation where I have two parent divs containing dynamic children divs, and I want to enable POST requests to PHP when items are dragged from one side to the other (and vice versa). Here is the Javascript code I am using: function allowDrop( ...

Changing class names when removing an element from an array

I have a data table where users can input information: <tbody> <tr class="wiring_details_6-73" id="wiring_rows_0"> <td colspan="2"> Wire Type: <select class="wire_selector_0" id="wiring_select_0" name="select_w ...

Customizing Jquery Validation Engine

Currently, I am trying to set up validation for a text field that should only accept alphanumeric characters and the forward slash (/) symbol. To achieve this, I am utilizing jquery validation engine. My initial attempt involved using class="validate[requ ...

Tips for displaying my libraries' function arguments while hovering in VSCode

As the creator of a JavaScript library, I am intrigued by how some libraries display function parameters and definitions when hovering over them in VSCode. Despite my efforts to add jsdoc style comments around the class definitions, I have not been able to ...