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

139
Vistas
Use different object property names for x and y axes

I have some data that is in this format:

[{"a": 123, "b": 234},{"a": 345, "b": 456}]

And I'm trying to represent this as a line chart with "a" as the x-axis, and "b" on the y-axis. But I can only get this to work if I convert the labels to "x" and "y", like this:

[{"x": 123, "y": 234},{"x": 345, "y": 456}]

That's clearly undesirable for large datasets. How can I get Highcharts to understand that I want to use different property names for the x and y axes?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

A very simple way would be:

o[ new_key ] = o[ old_key ];
delete o[ old_key ];
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can map your data to the format required by Highcharts. For example:

Highcharts.chart('container', {
    series: [{
        data: data.map(dataEl => [dataEl.a, dataEl.b])
    }]
});

Live demo: http://jsfiddle.net/BlackLabel/z4yr7vxs/

API Reference: https://api.highcharts.com/highcharts/series.line.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