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

216
Views
Pass data from JSON to HTML

So I got this from a design tool we have at our service. This div class is suppose to be added on pages where we want to generate a Gauge chart with given information.

<div class="gauge" id="g0" data-settings='
  {
    "value": 9,
    "min": 0,
    "max": 100,
    "units": "%",
    "limits": [
      {"from": 0, "to": 30, "color": "green", "label": "Low attrition"},
      {"from": 31, "to": 70, "color": "gray", "label": "Moderate attrition"},
      {"from": 71, "to": 100, "color": "red", "label": "High attrition"}
    ]
  }'
></div>

So what I need to learn is how I modify the values passed into data-settings here to make the Gauge chart more dynamic. I'm gonna get some data by parsing a JSON which I get from the backend.

var Data = JSON.parse("{{data_attrition|escapejs}}");

And this I want to pass into some of the variables in data-settings, for example change "value" from 9 to whatever I get from the backend.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I see you use JS, so one option is to utilize jquery's .get() method to make a request to thee server to get a the JSON in the form you need (based on some parameters maybe), and the use .html() or data() properties to set the data dynamically. Check this as a start: https://api.jquery.com/data/

about 4 years ago · Juan Pablo Isaza Report
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!