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

369
Vistas
Highcharts data from a variable is not working but from works fine from an array

I am very new to JavaScript and Highcharts so thank you in advance. I am trying to create a simple chart using Highcharts. When I manuayy create the variable using this array the chart works:

let result = [1084.58,1084.65,1084.64]

However, when when I grab the data from JSON and put that into the variable the chart does not show the data. If I "alert" the variable that is created from the JSON is appears like this:

1084.58,1084.65,1084.64

I am guessing the format of the data from the JSON is not correct. What should I do to correct it?

When I use the manually created variable the chart appears correctly. When I create the variable from the JSON file the chart appears and the X axis has the correct labels but no data in the chart.

I did some testing and found what I think is the issue. The variable that is created from the JSON has quotes around each entry. How can I remove the quotes?

['1084.58', '1084.65', '1084.64']
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You'll probably need to convert those values to Number type (using Number() or parseFloat()), you can do something like this:

variable => contains ['1084.58', '1084.65', '1084.64']

variable = variable.map(number => {return Number(number)})

Since you're new to Javascript (Welcome to this language!), I'm gonna explain how it works. "map" is an array method which takes each element of an array and returns an value (simillar to forEach method, but forEach doesn't return anything). So when using map to return each element of an array like this you're pushing the new element to the new array, it will be something like

variable.map(number => {return Number(number)})

On the 1st element: It returns Number('1084.58'), then it returns 1084.58 (number type)

On the 2nd element: It returns Number('1084.65'), then it returns 1084.65 (number type)

On the 3rd element: It returns Number('1084.64'), then it returns 1084.64 (number type)

Each return into this new variable is like an array.push(element)

Hope you got the idea

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