javascript - ChartJS -- How do I change scale color when I have to scales? - Stack Overflow

I created a nice little chart with two scales using two datasets. I have read the documentation for Char

I created a nice little chart with two scales using two datasets. I have read the documentation for ChartJS pretty thoroughly, but I can't seem to find out how to add specific colors to the chart scales (numbers). The left scale should be orange and the right one blue. Is this even possible, and if so, how do I do it? I don't think it's necessary for me to supply any source code for the chart itself, but let me know if it is.

I created a nice little chart with two scales using two datasets. I have read the documentation for ChartJS pretty thoroughly, but I can't seem to find out how to add specific colors to the chart scales (numbers). The left scale should be orange and the right one blue. Is this even possible, and if so, how do I do it? I don't think it's necessary for me to supply any source code for the chart itself, but let me know if it is.

Share asked Jan 5, 2017 at 12:26 PellePelle 7411 gold badge9 silver badges18 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Take a look at "Tick Configuration" under "Scales". You need to set the fontColor option for each axis. Like this:

options: {
    scales: {
        yAxes: [{
            ticks: {
                fontColor: "#666"
            }
        }]
    }
}

With Chart.js 4.3.1, the configuration could look like this:

{
    options: {
        scales: {
            y: {
                title: {
                    text: 'Some title',
                    display: true
                },
                ticks: {
                    color: 'blue' // can also use hex color codes
                }
            }
        }
    }
}

See the documentation for Common tick options to all axes.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745054280a4608570.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信