Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

217
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda