Chartjs-Chart.js – Override inherited colors when coloring graphs

1👍

color is not a valid dataset property for a line chart. Use borderColor and optionally also backgroundColor (will be used for drawing the legend label box).

function getChartDataObject(data){
    var title = data['metadata']['title'];
    var color = random_rgba();
    console.log(`Color: ${color}`);
    var dataObject = {
        label: title,
        data: data['scaled_interval'],
        borderColor: color, // <- to be changed
        fill: false,
        lineTension: 0,
        radius: 1,
    }
    return dataObject;
}

For further information, please consult Dataset Properties from the Chart.js documentation.

Leave a comment