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 }))
}]
- [Chartjs]-Possible to hide Chart.js grid lines that extend beyond chart?
- [Chartjs]-How to draw the stroke behind bars in Chart.js?
Source:stackexchange.com