[英]charts js change line chart axis font size/color and background lines
我一直試圖改變背景線的顏色,以及軸的字體大小和顏色,但無濟於事。 我目前正在使用最新版本的charts.js,似乎無法弄清楚如何進行更改。 在舊版本的圖表中,我可以更改它們,但該代碼不再有效。
這是我的代碼:
var lineoptions = {
legend:{
display:false
},
scales:{
yAxes:[{
display:false
}]
},
tooltips:{
enabled:false
},
elements:{
point:{
radius:4,
borderWidth:2
}
}
};
var linedata = {
labels:[
"618",
"39",
"1734",
"3459"
],
datasets:[
{
data:[618,39,1734,3459],
fill:false,
borderColor:"rgba(227,6,20,1)",
pointBorderColor:"rgba(227,6,20,1)",
pointBackgroundColor:"rgba(255,255,255,1)",
pointHoverBackgroundColor:"rgba(255,255,255,1)",
pointHoverBorderColor:"rgba(227,6,20,1)",
}]
};
var linechart = document.getElementById("canvas-line").getContext("2d");
var myLineChart = new Chart(linechart,{
type:'line',
data:linedata,
options:lineoptions
});
*編輯*
我設法通過使用以下方法更改軸信息的顏色:
defaultFontColor:'#6d6e71',
但我仍然需要弄清楚如何更改圖表本身的背景線(x和y線)。
好的,我弄清楚了:
scales:{
xAxes:[{
gridLines:{
color:"rgba(255,255,255,0.5)",
zeroLineColor:"rgba(255,255,255,0.5)"
}
}],
yAxes:[{
display:false
}],
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.