Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
Flexible layout on graph in javascript

in javascript i'm making a quiz. answers are displayed by a vertical bar chart. I draw this chart in javascript by using a fixedvalue and multiplying it with the input of the range objects.

The problem with this is that it doesn't recognize the width of the browser or translate to mobile at all. How can i request the screen width? and make it so that the graph stays neat within the browser Thank you for your help !, pls elaborate a little bit as i am new to javascript

 ranges.forEach((range) => {
    const rangeVal = parseInt(document.getElementById(range).value);
    result += rangeVal; // add value to counter
    var chart1value;
    var fixedValue = 100
    var barWidth1 = document.querySelector("#bar-one");
    chart1value = result;
    chart1value = chart1value * fixedValue;
    document.getElementById('bar-one').value = chart1value;
    barWidth1.style.width = chart1value + "px";
});

Update :

so i've requested Browser width of the screen with jquery. but it's a static width. Does anybody know if this

 var width = $(window).width();


ranges.forEach((range) => {
    const rangeVal = parseInt(document.getElementById(range).value);
    result += rangeVal; // add value to counter
    var chart1value;
    // var fixedValue = 100
    var barWidth1 = document.querySelector("#bar-one");
    chart1value = result;
    chart1value = chart1value * width * 0.9 / 10;
    document.getElementById('bar-one').value = chart1value;
    barWidth1.style.width = chart1value + "px";

});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!