score:1

Accepted answer

The Highchart examples show another example to setup the chart. The following format can be used:

$(document).ready(function() {
  $.getJSON("myPHPFile.php", function(json) {
    var series = json.map(function(record){
        return [record.Year, record.Number];
    })

    Highcharts.chart('container', {
      chart: {
        renderTo: 'container',
        type: 'line',
      },
      xAxis: {
        title: {
          text: 'Year'
        }
      },
      yAxis: {
        title: {
          text: 'Number'
        },
      },
      series: [{
        data: series
      }],
    });

  });
});

Checkout the live demo below:

const data = [{
  "Year": 2016,
  "Number": 41
}, {
  "Year": 2017,
  "Number": 512
}, {
  "Year": 2018,
  "Number": 1895
}, {
  "Year": 2019,
  "Number": 3132
}];

const series = data.map(record => [record.Year, record.Number])

Highcharts.chart('container', {
  chart: {
    renderTo: 'container',
    type: 'line',
  },
  xAxis: {
    title: {
      text: 'Year'
    }
  },
  yAxis: {
    title: {
      text: 'Number'
    },
  },
  series: [{
    data: series
  }],
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<div id="container"></div>


Related Query

More Query from same tag