javascript – Chart.js文字颜色

前端之家收集整理的这篇文章主要介绍了javascript – Chart.js文字颜色前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以即时通讯使用chart.js
http://www.chartjs.org/docs/
我无法改变底部文字的颜色

例如:
“一月”,“二月”,“三月”,“四月”,“五一”,“六一”,“七一”
以及左侧的数字

我尝试了所有这些选项:
scaleFontColor:“#FFFFFF”
pointLabelFontColor:“#FFFFFF”

我的完整代码

<script>
    var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
    var lineChartData = {
        labels : ["January","February","March","April","May","June","July"],datasets : [
            {
                label: "My Second dataset",fillColor : "rgba(255,89,114,0.6)",strokeColor : "rgba(51,51,1)",pointColor : "rgba(255,pointStrokeColor : "#fff",pointHighlightFill : "#fff",pointHighlightStroke : "rgba(151,187,205,maintainAspectRatio: false,scaleFontColor: "#FFFFFF",pointLabelFontColor : "#FFFFFF",pointLabelFontSize : 30,data : [1,2,10,7,3,1]
            }
        ]

    }

window.onload = function(){
    var ctx = document.getElementById("canvas").getContext("2d");

    window.myLine = new Chart(ctx).Line(lineChartData,{
        responsive: true
    });
}


</script>

解决方法

scaleFontColor用于更改标签的颜色.

您应该将它作为参数添加函数中,而不是将其放在数据集中,如下所示:

window.myLine = new Chart(ctx).Line(lineChartData,{
    responsive: true,scaleFontColor: "#FFFFFF" }
});
原文链接:https://www.f2er.com/js/158948.html

猜你在找的JavaScript相关文章