Chart.js文字颜色 [英] Chart.js Text color

查看:522
本文介绍了Chart.js文字颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我使用chart.js
http://www.chartjs.org/docs/
我无法更改底部文字的颜色

So im using chart.js http://www.chartjs.org/docs/ and i cant change the color of the text in the bottom

ex:
January,February,March ,四月,五月,六月,七月
和左侧的数字

ex: "January","February","March","April","May","June","July" and the numbers in the left side

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

i tried all these options: 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, 51, 1)",
                pointColor : "rgba(255, 89, 114, 1)",
                pointStrokeColor : "#fff",
                pointHighlightFill : "#fff",
                pointHighlightStroke : "rgba(151,187,205,1)",
                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 用于更改标签的颜色。

scaleFontColor is used to change the color of the labels.

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

Instead of putting it in your datasets you should add it as a parameter in your function, like this:

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

这篇关于Chart.js文字颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆