Chart JS V2 Default Font Color not working

Can’t get the defaultFontColor to work in my chart at all.

Really need help on this.

Thanks

var ctx = document.getElementById("performance-chart").getContext("2d");
            var myChart = new Chart(ctx, {
                type: 'line',
                data: {
                    labels: ["Jun", "July", "Aug", "Sept", "Oct", "Nov"],
                    datasets: [
                        {
                            fill: true,
                            backgroundColor: 'rgba(169, 205, 221, 0.8)',
                            borderColor: 'rgba(169, 205, 221, 0.8)',
                            data: [5, 8, 6, 12, 10, 11]
                        },
                        {
                            fill: true,
                            backgroundColor: 'rgba(64, 158, 192, 0.8)',
                            borderColor: 'rgba(64, 158, 192, 0.8)',
                            data: [10, 14, 8, 16, 15, 17]
                        }
                    ]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: true,
                    defaultColor: 'rgba(0,0,0,0.1)',
                    defaultFontColor: '#fff',
                    scales : {
                        yAxes : [{
                            display: false,
                        }]
                    },
                    showLines : true,
                    legend : {
                        display: false
                    },
                    elements : {
                        line : {
                            tension: 0,
                            borderWidth: 0.1,
                            fill: false
                        },
                        point : {
                            radius: 0,
                            borderWidth: 0
                        }
                    }
                }
            });```

Author: Fantashit

2 thoughts on “Chart JS V2 Default Font Color not working

  1. Try the following near the top of your code:

    var ctx = document.getElementById(“performance-chart”).getContext(“2d”);
    Chart.defaults.global.defaultFontColor = ‘#fff’;
    Chart.defaults.global.defaultColor = ‘rgba(0,0,0,0.1)’;
    var myChart = new Chart(ctx, {

Comments are closed.