[Chartjs]-How to include many datapoints to plot in chart.js

1👍

Try concatenating the arrays like so:

//var xArray = [{x: ?,y: ?}, {x: ?,y: ?}];
//var yArray = [{x: ?,y: ?}, {x: ?,y: ?}];
var concatenatedArray = xArray.concat(yArray);

Then, you can pass that in when you’re invoking your chart like so:

var scatterChart = new Chart(ctx, {
type: 'line',
data: {
    datasets: concatenatedArray
},
options: {
    scales: {
        xAxes: [{
            type: 'linear',
            position: 'bottom'
        }]
    }
}
});

I hope this helps – keep me posted!

Leave a comment