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 8866073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:41:19+00:00 2026-06-14T16:41:19+00:00

I am trying to develop a dynamic funnel graph using JavaScript and HTML5 canvas.

  • 0

I am trying to develop a dynamic funnel graph using JavaScript and HTML5 canvas. I can draw the elements just fine, the only problem I have is with my math. I want my graph to have a linear slope on each side to make an upside-down cone. The problem is that I don’t know if it can be done with the amount of information I have. So, here is the info I do have:

  1. The width and height of the total graph (250×300 respectively)
  2. The length of the two main bases of the whole graph (250 and 30)
  3. The area of the total graph (42000 pixels) ((250+30)/2)*300
  4. The number of how many stages there will be (let’s say 3 for simplicity)
  5. The percentage of the area each stage will take (let’s say 30%, 50%, and 20% for each stage)
  6. The slope/angle of the graph (rise/run) 300/110 (It’s not a perfect triangle and the second base has a length of 30)

Each stage will be a trapezoid (as well as the graph itself).
Now, what formula can I use to create a funnel graph that will make each stage the correct height given the slope and the first base of the stage’s trapezoid?

I have tried and tried and I just can’t seem to make the math work. Either one stage is too long for the slope, or another is too small, which causes the slope to be inconsistent. I need the slope to be consistent and for only the stage’s height to change.

The closest image I can find to represent what I want is this:

http://dwh01.unife.it/microstrategy/help/WebUser/WebHelp/Lang_1033/images/defining_funnel_widget.gif

  • 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-14T16:41:21+00:00Added an answer on June 14, 2026 at 4:41 pm

    I appreciated eh9’s answer, but I honestly am not smart enough to solve that sort of equation through JavaScript. However, I ended up coming up with a solution that I will outline here.

    1. Find the length of base 1 on whatever stage you’re on. (If it’s the first stage, it’s the width of the graph).
    2. Calculate the area that the next stage needs to be. I’m passing in a percent and since I know the total area of the whole graph, I can multiply that area by the percent and find the area of the stage to draw.
    3. Iterate through a for loop with ‘i’ being the height and the condition being i <= graph_height.

      1. Calculate the second base length with the given height (i) and the slope by using this equation: b2 = (b1 – ((i/slope)*2))).
      2. Calculate the new temporary area of the stage given that height.
      3. Push the difference of the temporary area and what the area should be into an array along with the height (i).
    4. Sort the array placing the lowest difference area difference as the first element in the array.

    5. You now have an array that contains, in it’s first element, the smallest area difference with its corresponding height.

    Therefore, now you have the height of the stage given its area. This is all you need along with the first base and the slope to figure out the second base’s length and position.

    This is not the most efficient solution (mainly due to the computational guesswork that is done), but it does work and it is accurate.

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

Sidebar

Related Questions

I'm trying to develop business logic for a dynamic site using nusoap on server
I've been trying to develop a dynamic library in C++ that can be run-time
Im trying to develop a class in JavaScript I can use to access a
I am trying to develop an application for my localhost on which I can
I am trying to develop the XMPP Gateway which can send/receive from standard XMPP
trying to develop web form using jquery. all i need is to have several
We are trying to develop a strategy for using elasticsearch for full-text searching on
I'm currently trying to develop a project based upon Firemonkey. I'm using Firemonkey for
I am trying to develop one simple application using Java, Flex and Blazeds. I
I was trying to develop a small web service using eclipse and deploying it

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.