[Chartjs]-Problem creating scatter graph using chart.js

1👍

Your data is not of valid JSON format, individual properties need to be separated by a comma each. There’s also an error inside the generateData function with the assignment to the y property. It should be rewritten as follows:

function generateData() {
  var data = [];
  json.elements.forEach(element => {
    data.push({
      x: element.now_cost,
      y: element.points_per_game
    });    
  });
  return data;
}

Or you could even get rid of this function generateData and assign data directly as follows:

dataset: [{
    data: json.elements.map(e => ({ x: e.now_cost, y: e.points_per_game }))
}]

Leave a comment