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

  • SEARCH
  • Home
  • 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 9171019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:06:23+00:00 2026-06-17T16:06:23+00:00

I just tried to code some tricks on justGage (using Raphael JS code) to

  • 0

I just tried to code some tricks on justGage (using Raphael JS code) to calculate percentages but I’m stuck on mathematical formula 🙁 .

Here’s the point :
I have a div with 400px width that welcomes a svg justGage.
I would like to make it filling following mouse clicking. For example, clicking on bottom right of the half-circle will fill it as if it was 100% filled. Clicking on bottom left, fill it at 0%.
The issue is that I try to catch mouse position and use it to refresh the Gage, but working only on X axis is not following circle shape.

Here’s my basic calculation :

    var parentOffset = $(this).offset(); 
    var relX = e.pageX - parentOffset.left;
    g1.refresh(Math.round((relX)/4));

And the whole code test fiddle.

Does anyone know a formula to really follow the circle shape ?

  • 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-17T16:06:24+00:00Added an answer on June 17, 2026 at 4:06 pm

    Since you have a strip which the clicks happen, you cannot rely on the x-coordinate in order to decide the precentage. The best option I could think of was using trigonometry to calculate the angle between the click and the center of the circle, before fitting it to your range 0-100 by this equation ((angel/Math.PI)*100).

    Below is a code snipplet that worked out for me.

    $(function(){
        $("#g1 path").click(function(e){
            var parent = $(this).parent();
            var height = parent.height();
            var width = parent.width();
            var center = {'x': width/2, 'y':(height-60)};
            var angle = Math.atan2(-(e.pageY - center['y']), center['x'] - e.pageX);
            g1.refresh(Math.round((angle/Math.PI)*100));  
        });
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is just some pretty standard code I have tried. What I am trying
I just tried the following code, but the result seems a little strange. It
I just tried disassembling some shellcode using disasm and I found the following statement
It's bothering me what delete [] actually does, so I just tried some code
I've just tried example code for SSL shown here ; it is much interesting
I've just tried some simple code from example: $(document).ready(function() { var map = OpenLayers.Map('map-content',
Iam running WAMP server and just enabled php_memcache extension and have tried the code
I'd like to make a subclass of NSInputStream. Simply, I tried to code just
I am just learning Perl's comparison operators. I tried the below code :- $foo=291;
Just tried some small graphics application of mine on Windows 7, and I'm getting

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.