在Chart.js中更改X和Y轴值的颜色 [英] Change color of X and Y axis values in Chart.js
问题描述
我正在使用v2.*.但是,我似乎无法为折线图设置默认颜色.我主要是想设置x/y图表值的颜色.我认为下面的方法可以做到-但它对图表完全没有任何作用.
I'm using v2.*. However, I can't seem to set the default color for a line chart. I'm mainly looking to set the color of the x/y chart values. I figured the below might do it - but it does nothing to the chart at all.
Chart.defaults.global.defaultColor = 'orange',
更新
这是带有实时图表的jsfiddle.简而言之,我想更改标签的颜色,例如2016年2月7日,等等.
Update
Here's a jsfiddle with live chart. In short, I'm looking to change the color of the labels i.e. Feb 7, 2016, etc etc.
https://jsfiddle.net/o534w6jj/
推荐答案
好的,所以我知道了.这是我正在寻找的ticks
属性...请参见下面的代码.
Okay, so I figured it out. It's the ticks
property I'm looking for...see code below.
请参阅更新的jsfiddle: https://jsfiddle.net/o534w6jj/1/
See updated jsfiddle: https://jsfiddle.net/o534w6jj/1/
var ctx = $("#weekly-clicks-chart");
var weeklyClicksChart = new Chart(ctx, {
type: 'line',
data: data,
scaleFontColor: 'red',
options: {
scaleFontColor: 'red',
responsive: true,
tooltips: {
mode: 'single',
},
scales: {
xAxes: [{
gridLines: {
display: false,
},
ticks: {
fontColor: "#CCC", // this here
},
}],
yAxes: [{
display: false,
gridLines: {
display: false,
},
}],
}
}
});
这篇关于在Chart.js中更改X和Y轴值的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!