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

136
Views
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 answers
Answer question

0

A very simple way would be:

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

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 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!