Chartjs-$.function is not a function – jQuery

0👍

This was caused by my lack of understanding of chart.js

I was missing a needed function convertHex() that I assumed was created by my colleague and then just not used.

Basically syntax errors and missing functions led to confusing error statements.

Function:

function convertHex(hex,opacity){
    hex = hex.replace('#','');
    var r = parseInt(hex.substring(0,2), 16);
    var g = parseInt(hex.substring(2,4), 16);
    var b = parseInt(hex.substring(4,6), 16);

    var result = 'rgba('+r+','+g+','+b+','+opacity/100+')';
    return result;
}

Leave a comment