Chartjs-Node.js How to save data from pg database into variable

0👍

You will need to replace your empty labels array with the values of the objects, you can achieve this using a map like so:

var ctx = document.getElementById('radar');
var chart = new Chart(ctx, {
    type : 'radar',
    data: {
        labels: labelsFromDb.map((el) => el.name),
        datasets: [{
            label: "data_0",
            data: [],
            backgroundColor: ["rgba(255, 255, 132, 0.2)"]
        }]
    }
});

function addData(){...}
function removeData(){...}

Leave a comment