Change label font color for a line chart using Chart.js

后端 未结 1 1303
一整个雨季
一整个雨季 2020-12-07 00:47

I\'m using Chart.js to generate some charts. The line chart requires labels. I can\'t seem to figure out a way to change the color of those labels.

var chart         


        
相关标签:
1条回答
  • 2020-12-07 01:43

    Yes, the scaleFontColor option changes the color of labels.

    You probably tried to add it to the data object, that's why it didn't work. Actually it should be passed as a second parameter of the Line function like this:

    var myLine = new Chart(document.getElementById("cpu-chart").getContext("2d"))
        .Line(lineChartData, { scaleFontColor: "#ff0000" });
    

    Edit:

    Similarly, to change the font size use scaleFontSize.

    Example:

    scaleFontSize: 16
    
    0 讨论(0)
提交回复
热议问题