Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9128229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:27:59+00:00 2026-06-17T07:27:59+00:00

I’m trying to code something like this – I’d love to add my coding

  • 0

I’m trying to code something like this –

enter image description here

I’d love to add my coding attempt, only I don’t really have a clue. When googling stuff like “jQuery countdown”, “pie chart” etc. I find only plugins, where I want to code it myself. I’m not even sure whether this should be done with html5 canvas, jQuery or both..

What should be my first step?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:28:00+00:00Added an answer on June 17, 2026 at 7:28 am

    Drawing a “pie” section of a circle is a fairly trivial task.

    For example:

    ctx.fillStyle = "#f00";
    ctx.beginPath();
    ctx.moveTo(50,50);
    ctx.arc(50,50,50, sta, sta + 2*Math.PI*pct);
    ctx.fill();
    

    The above code will draw an arc with a radius of 50 pixels. the forth and fifth parameters determine where the arc starts and ends. In your case, you want:

    var sta = -Math.PI/2; // this is -90 degrees (or "up")
    

    The variable pct is the percentage of the circle to be filled.

    The real objective of your question is the Timer. I’ve created a simple Timer class that is very flexible with its output:

    function Timer(duration /* in ms */ , props) {
        this.ontick = props && typeof props.ontick === "function" ? props.ontick : function() {};
        this.onend = props && typeof props.onend === "function" ? props.onend : function() {};
        this.interval = props && typeof props.interval === "number" ? props.interval : 1000 / 10;
        this.elapsed = 0;
    
        var running = false,
          start, end, self = this;
    
        this.start = function() {
          if (running) return this;
    
          start = new Date().getTime();
          end = start + duration;
          tick();
          running = true;
    
          return this;
        };
    
        function tick() {
          var now = new Date().getTime();
          self.ontick.call(self);
          self.elapsed = now - start;
    
          if (now < end) setTimeout(tick, self.interval);
          else self.onend.call(self);
        }
      }
    

    Very basic usage of the Timer class could be something like this:

    var timer = new Timer(10 * 1000, {
        ontick:function(){
            console.log(this.elapsed);
        },
        onend:function(){
            console.log('all done');
        }
    }).start();
    

    The nice thing about this Timer implementation is that it isn’t cluttered with logic unrelated to counting down time, so it is very reusable.

    I’ve created a sample of the output you would like here: http://jsfiddle.net/9jZsb/6/

    You can see that I’m creating the animation myself, but it should be trivial to incorporate other libraries into this solution to accomplish a similar effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.